我有以下数据框:
Date Open ... Close Volume
0 1535932800000 7302.00000000 ... 7282.30000000 1216.44169400
1 1535936400000 7282.30000000 ... 7271.64000000 1342.62260700
2 1535940000000 7271.64000000 ... 7281.21000000 1200.83689100
3 1535943600000 7282.99000000 ... 7263.02000000 984.70504600
4 1535947200000 7263.48000000 ... 7210.46000000 2070.88296500
[5 rows x 6 columns]
我的问题是我想格式化Date
列以获取正确的日期格式。我使用以下行:
klines2['Date'] = datetime.fromtimestamp(klines2.Date/1000)
我遇到以下错误:
Traceback (most recent call last):
File "D:\python_cwiczenia\binanceBot\binancebot.py", line 20, in <module>
klines2['Date'] = datetime.fromtimestamp(klines2.Date/1000)
File "C:\Users\PZAWA\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\series.py", line 118, in wrapper
"{0}".format(str(converter)))
TypeError: cannot convert the series to <class 'int'>
我尝试了几种选择,但我总是遇到此错误。我想要实现的输出是这样的:
>>> datetime.fromtimestamp(1535932800000/1000)
datetime.datetime(2018, 9, 3, 2, 0)
我在做什么错了?