Python:将datetime.datetime转换为DatetimeIndex

尝试使用DataFrameclient将一些数据写入数据库(InfluxDB),但显然我的时间戳格式不正确:

DataFrameclient.write_points(json_body,measurement=Obj.project_handle,protocol='json')

File "/usr/lib/python3.6/site-packages/influxdb/_dataframe_client.py",line 131,in write_points
File "/usr/lib/python3.6/site-packages/influxdb/_dataframe_client.py",line 230,in _convert_dataframe_to_json
raise TypeError('Must be DataFrame with DatetimeIndex or '
TypeError: Must be DataFrame with DatetimeIndex or PeriodIndex.

好像我必须将时间戳转换为DatetimeIndex格式...我正在尝试用pd.DatetimeIndex(datetime_index)来获取错误:

DatetimeIndex() must be called with a collection of some kind,datetime.datetime(2019,11,18,21,39,596050,tzinfo=<UTC>) was passed.
zxtong961 回答:Python:将datetime.datetime转换为DatetimeIndex

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3078678.html

大家都在问