I'm trying to figure out how to fix the Timestamp to Datetime conversion for some ccxt data.
Here is the data I'm working with:
Timestamp Open High Low Close Volume
0 1506211200000 3779.54 3789.99 3622.76 3660.02 661.636390
1 1506297600000 3660.02 3979.87 3653.69 3920.75 727.994713
2 1506384000000 3928.00 3976.99 3850.05 3882.35 526.727987
3 1506470400000 3882.36 4249.94 3872.81 4193.00 628.170966
4 1506556800000 4192.11 4300.00 4101.00 4174.50 849.785325
Here is the format I'm trying to convert the 'Timestamp' column to, but I can't seem to iterate through and change them all individually:
Timestamp Open High Low Close Volume
0 2017-07-14 09:40:00 3779.54 3789.99 3622.76 3660.02 661.636390
1 2017-07-14 09:40:00 3660.02 3979.87 3653.69 3920.75 727.994713
2 2017-07-14 09:40:00 3928.00 3976.99 3850.05 3882.35 526.727987
3 2017-07-14 09:40:00 3882.36 4249.94 3872.81 4193.00 628.170966
4 2017-07-14 09:40:00 4192.11 4300.00 4101.00 4174.50 849.785325
I've tried everything I can think of and know I'm overcomplicating it.
Here are some of the things I've tried thus far and some of the returned errors:
df = pd.read_csv('binance-BTCUSDT-1d.csv', parse_dates=True)
# for ts in df['Timestamp']:
# print(timestamp.strftime('%Y-%m-%d %H:%M:%S'))
# returns the same datetime for all cells
# df['Timestamp'] = timestamp.strftime('%Y-%m-%d %H:%M:%S')
# returns the same datetime for all cells
# datetime.fromtimestamp(df['Timestamp']).strftime('%Y/%m/%d %H:%M:%S')
# cannot convert series to int
# timestamp = datetime.fromtimestamp(df['Timestamp'].astype(int))
# cannot convert series to int
# time.strftime("%D %H:%M", time.localtime(int(df['Timestamp'])))
# cannot convert series to int
# utc_time = datetime.fromtimestamp(df['Timestamp'], timezone.utc)
# cannot convert series to int
# local_time = utc_time.astimezone()
# cannot convert series to int
# print(local_time.strftime("%Y-%m-%d %H:%M:%S.%f%z (%Z)"))
# cannot convert series to int
# dates = [datetime.fromtimestamp (x[0] // 1000) for x in df['Timestamp']]
# int object is not subscriptable
# datetime.fromtimestamp(x[0]//1000 for sec in df['Timestamp'].astype(int))
# int is required, got type generator
# print(timestamp.strftime('%Y-%m-%d %H:%M:%S'))
# DateTimeParse(ToString([df['Timestamp']]),"%Y%m%d%H%M%S")
# datetime.utcfromtimestamp(df['Timestamp']).strftime('%Y-%m-%dT%H:%M:%SZ')
# time.ctime(int(df['Timestamp']))
# datetime.fromtimestamp(float(df['Timestamp']/1000))
df.head()```
[1]: https://i.stack.imgur.com/FwWyc.png
[2]: https://i.stack.imgur.com/Rc1Jm.png