Pandas
来自Jack's Lab
(版本间的差异)
(→Quick Start) |
(→Quick Start) |
||
第34行: | 第34行: | ||
2018-05-13 09:21:43 39.4 26.9 NOD78783243232 AABBCCDDEEFF | 2018-05-13 09:21:43 39.4 26.9 NOD78783243232 AABBCCDDEEFF | ||
+ | >>> from influxdb import DataFrameClient | ||
+ | >>> client = DataFrameClient(host='127.0.0.1', port=8086, database='mydb') | ||
+ | >>> client.write_points(d, 'test', tag_columns=['dev_id','mac'] | ||
+ | True | ||
</source> | </source> | ||
2018年5月15日 (二) 00:10的最后版本
[编辑] Quick Start
export from influxdb:
$ influx -host localhost -database mydb -format csv -execute "select * from temphumi where time <= 1526254976000000000" > test.csv
test.csv:
name,time,Humi,Temp,dev_id,mac temphumi,1526197529000000000,39.3,27.0,NOD78783243232,AABBCCDDEEFF temphumi,1526202738000000000,39.3,26.9,NOD78783243232,AABBCCDDEEFF temphumi,1526203290000000000,39.4,26.9,NOD78783243232,AABBCCDDEEFF temphumi,1526203298000000000,39.4,26.9,NOD78783243232,AABBCCDDEEFF temphumi,1526203303000000000,39.4,26.9,NOD78783243232,AABBCCDDEEFF
$ python Python 2.7.14 (default, Sep 23 2017, 22:06:14) >>> import pandas as pd >>> d=pd.read_csv('test.csv', date_parser=lambda x: pd.to_datetime(float(x)), index_col='time') >>> d=d.drop(columns=['name']) >>> d Humi Temp dev_id mac time 2018-05-13 07:45:29 39.3 27.0 NOD78783243232 AABBCCDDEEFF 2018-05-13 09:12:18 39.3 26.9 NOD78783243232 AABBCCDDEEFF 2018-05-13 09:21:30 39.4 26.9 NOD78783243232 AABBCCDDEEFF 2018-05-13 09:21:38 39.4 26.9 NOD78783243232 AABBCCDDEEFF 2018-05-13 09:21:43 39.4 26.9 NOD78783243232 AABBCCDDEEFF >>> from influxdb import DataFrameClient >>> client = DataFrameClient(host='127.0.0.1', port=8086, database='mydb') >>> client.write_points(d, 'test', tag_columns=['dev_id','mac'] True