import pandas as pd
import datetime
def open_csv(path):
try:
df = pd.read_csv(path)
return df
except FileNotFoundError:
print("ERR: FileNotFoundError", path)
data = open_csv("historical/BNBBTC")
for d in data["Open_time"]:
print(d)
print(type(d))
print(datetime.datetime.fromtimestamp(d).strftime('%Y-%m-%d %H:%M:%S'))
error:
1514764800000
Traceback (most recent call last):
<class 'int'>
File "D:/bot/add_data.py", line 16, in <module>
print(datetime.datetime.fromtimestamp(d).strftime('%Y-%m-%d %H:%M:%S'))
OSError: [Errno 22] Invalid argument
I can not understand what is the problem? If b = int ("1514764800000") then everything works!
import timeand replacedatetime.datetime.fromtimestamp(d).strftime('%Y-%m-%d %H:%M:%S')withtime.strftime('%Y-%m-%d %H:%M:%S')