When I look to a pd df :

I tell myself I would like to fill the upper left empty space by a dataframe name. Is that possible ?
(Here it would be to put a text on the empty cell on top of "Lib_ze" and on left of "nunique".)
You can use the rename() method of pandas. DataFrame to change column/index name individually. Specify the original name and the new name in dict like {original name: new name} to columns / index parameter of rename() .
Access the index of a DataFrame with pandas. DataFrame. index . Assign a title to the name attribute of the index.
To set column names of DataFrame in Pandas, use pandas. DataFrame. columns attribute. Assign required column names as a list to this attribute.
It is possible if set columns names:
df.columns.name = 'text'
Or rename_axis (new in pandas 0.18.0):
df = df.rename_axis('text', axis=1)
Sample:
df = df.rename_axis('text', axis=1)
print (df)
text              nunique
Lib_ze                295
cd_cmn              31870
cd_ze                 295
code_commune_zdc    31870
unite                 638
If set index name:
#df.index.name = 'text'
df = df.rename_axis('text')
print (df)
                  nunique
text                     
Lib_ze                295
cd_cmn              31870
cd_ze                 295
code_commune_zdc    31870
unite                 638
                        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