-
Notifications
You must be signed in to change notification settings - Fork 524
Can not work, issue show KeyError: '[0] not in index', need your great help .thanks. #497
Comments
MAC OS 10.12.1,python 2.7 |
I don't know whether you have got it resolved by now, and I just encountered the same keyerror issue today, for my situation it fixed by specifying the attribute "columns" explicitly with a string type '0' when create a DataFrame. As the code below: |
In fact, you can assign any string-based name to your columns. works: doesn't work: works: doesn't work: |
closing this since there's no issue |
Actually, i fixed it. |
Hi @SatoshiNewton , |
Current example code raises KeyError: '[0] not in index' and can be fixed by adding columns=['0'] to the DataFrame creation. Fixed issue #497
Create pandas DataFrame
Create database: demo
Write DataFrame
Traceback (most recent call last):
File "/Users/LeonYan/MyPython/QI/DF2influx.py", line 50, in
main(host=args.host, port=args.port)
File "/Users/LeonYan/MyPython/QI/DF2influx.py", line 25, in main
client.write_points(df, 'demo', protocol=protocol)
File "/Users/LeonYan/Library/Python/2.7/lib/python/site-packages/influxdb/_dataframe_client.py", line 125, in write_points
field_columns=field_columns)
File "/Users/LeonYan/Library/Python/2.7/lib/python/site-packages/influxdb/_dataframe_client.py", line 220, in _convert_dataframe_to_json
dataframe[field_columns].to_dict('record'))
File "/Users/LeonYan/Library/Python/2.7/lib/python/site-packages/pandas/core/frame.py", line 1958, in getitem
return self._getitem_array(key)
File "/Users/LeonYan/Library/Python/2.7/lib/python/site-packages/pandas/core/frame.py", line 2002, in _getitem_array
indexer = self.loc._convert_to_indexer(key, axis=1)
File "/Users/LeonYan/Library/Python/2.7/lib/python/site-packages/pandas/core/indexing.py", line 1231, in _convert_to_indexer
raise KeyError('%s not in index' % objarr[mask])
KeyError: '[0] not in index'
The text was updated successfully, but these errors were encountered: