I have some code which is pulling data into a pandas dataframe.
df = df[["date","high","low","open","close"]]
The data looks like this:
date high low open close
0 1499140800 2615.390000 2600.000000 2610.58000 2603.00000
1 1499155200 2618.785462 2582.002100 2615.00000 2607.00000
2 1499169600 2617.674406 2550.314214 2607.00000 2554.55010
3 1499184000 2572.962113 2519.967440 2554.55010 2519.96744
4 1499198400 2595.654622 2516.000000 2519.96744 2580.00000
I am wanting to convert the unix timestamp column with an actual datetime. Earlier in my code am having to import
from datetime import datetime
and it seems to be giving me an error when I try to use datetime.datetime to convert. I can't just use import datetime
because this gives me an error on my previous import which I need. So my question is twofold. How can I convert the timestamp into a datetime (possibly without using the datetime module?) and how can I overwrite the date column with the new date time before I save into a file?I have tried several approaches but none seem to be giving me any luck..