无法将Python列表转换为timeSeries

我试图解决这个问题超过一天.我有这种类型的清单:

TempList[:5]
[(datetime.datetime(2015, 11, 25, 7, 29, 28, 337000),), (datetime.datetime(2015, 9, 8, 7, 44, 55, 53000),), (datetime.datetime(2015, 9, 10, 5, 44, 51, 867000),), (datetime.datetime(2015, 9, 10, 1, 42, 15, 740000),), (datetime.datetime(2015, 9, 2, 1, 7, 09, 687000),)]

我想将它转换为Pandas Time Series.
我发现这很有用function: pd.to_datetime.但是当我尝试的时候
转换它:

Dates = pd.to_datetime(TempList)

我收到此错误

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pandas/util/decorators.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pandas/tseries/tools.py", line 291, in to_datetime
    unit=unit, infer_datetime_format=infer_datetime_format)
  File "/usr/local/lib/python2.7/dist-packages/pandas/tseries/tools.py", line 427, in _to_datetime
    return _convert_listlike(arg, Box, format)
  File "/usr/local/lib/python2.7/dist-packages/pandas/tseries/tools.py", line 341, in _convert_listlike
    raise TypeError('arg must be a string, datetime, list, tuple, '
TypeError: arg must be a string, datetime, list, tuple, 1-d array, or Series

但是TempList是一个清单!我无法理解如何解决这个问题.我怎样才能转换我的清单?
谢谢!

解决方法:

你有一个元组列表.尝试将其转换为普通列表,然后使用pd.to_datetime.
像(我现在没有python)

tl2 = [ ti[0] for ti in TempList ]
Dates = pd.to_datetime(tl2)

PS1:你在TempList中还有什么? (你只显示前5个元素).

PS2:您可能需要使用format参数,请参阅https://stackoverflow.com/a/26763793/2707864.

相关文章

转载:一文讲述Pandas库的数据读取、数据获取、数据拼接、数...
Pandas是一个开源的第三方Python库,从Numpy和Matplotlib的基...
整体流程登录天池在线编程环境导入pandas和xrld操作EXCEL文件...
 一、numpy小结             二、pandas2.1为...
1、时间偏移DateOffset对象DateOffset类似于时间差Timedelta...
1、pandas内置样式空值高亮highlight_null最大最小值高亮背景...