I'm wondering how to get the Date column values. The 'Date' column doesn't show when typing df.columns. I'm trying to get this df into a Json file with df.to_json(), which get all values but the Date. Thank you all.
Open High Low Close
Date
2020-03-16 36.01 41.40 36.01 39.04
2020-03-17 40.50 43.57 39.11 41.51
2020-03-18 38.80 40.87 35.70 38.65
2020-03-19 37.50 39.00 35.26 36.40
2020-03-20 37.90 39.41 34.71 35.19
In [49]: type(df) Out[49]: pandas.core.frame.DataFrame
Looks like Date
is currently in the index. If you would like it to be a column, you just have to reset the index:
df.reset_index(inplace=True)
It doesn't appear because it's not really a column, it's the index. It shouldn't matter, however, because by default, df.to_json()
will by default include the index. It says so in the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With