Pandas Create Dataframe With Index Name As Column Name November 28, 2023 Post a Comment I have an existing dataframe with column name and data. I want to change index.name for dataframe to be column's name. I am confused about multi - indexing how do I do that? BecausSolution 1: It depends if MultiIndex or not.For single index need:df.index.name = 'foo'df = df.rename_axis('foo') CopyFor MultiIndex need:df.index.names = ('foo', 'bar') df = df.rename_axis(('foo', 'bar')) Copy Share Post a Comment for "Pandas Create Dataframe With Index Name As Column Name"
Post a Comment for "Pandas Create Dataframe With Index Name As Column Name"