0

I am using pandas, and when I do print(df), the result says as follows:

                        open      high       low     close        volume
2021-01-26 09:00:00  0.000230  0.000236  0.000228  0.000228    303.813500
2021-01-27 09:00:00  0.000226  0.000230  0.000223  0.000230   1479.338775
[2 rows x 5 columns]

The problem is that the very first date column has no name and seems not to be regarded as an actual column (it says it has only 5 columns). How can I put a name on the first column?

NAM
  • 9
  • 3

2 Answers2

0

It looks like the lef-most column is the index. You can set a name via:

df.index.name = 'my_pretty_name'
Nicolas Busca
  • 1,100
  • 7
  • 14
0

The first column in this case seems like an index
You can set a name for the index using

df.index.name = 'date'

It can be used as a column if use

df.index.name = 'date'
df = df.reset_index()
imdevskp
  • 2,103
  • 2
  • 9
  • 23