Isha
Isha

Reputation: 55

Column not visible in DataFrame.info()

I have the following DataFrame called large5:

country     United Arab Emirates    Djibouti    Andorra     Saudi Arabia    Marshall Islands
1971-1980   NaN                     NaN         NaN         NaN             NaN
1981-1990   1.082990                0.686978    0.370541    0.603019        0.410776
1991-2000   0.738127                0.366770    0.335852    0.370899        0.225249
2001-2010   1.270588                0.208094    0.255028    0.296046        0.097677
2011-2020   0.254555                -0.078750   -0.212721   0.025291        -0.165853
diff        0.828435                0.765728    0.583262    0.577727        0.576628

On running large5.info() I am not able to view the column 'country', and hence not able to rename, or use it in my visualization

<class 'pandas.core.frame.DataFrame'>
Index: 6 entries, 1971-1980 to diff
Data columns (total 5 columns):
United Arab Emirates    5 non-null float64
Djibouti                5 non-null float64
Andorra                 5 non-null float64
Saudi Arabia            5 non-null float64
Marshall Islands        5 non-null float64
dtypes: float64(5)
memory usage: 288.0+ bytes

Running large5.reset_index(inplace=True) is not working either, as the column name changes to 'index', and I am not able to rename it or use it correctly in my visualization. Any suggestions would be appreciated.

Upvotes: 1

Views: 224

Answers (1)

jezrael
jezrael

Reputation: 862406

Use DataFrame.rename_axis first:

largenew = large5.rename_axis('Date').reset_index()

Upvotes: 1

Related Questions