Pandas provides a convenient way to handle data and its transformation. Let’s see how can we convert a column to row name/index in Pandas.
Create a dataframe first with dict of lists.
Method #1: Using set_index() method.
Now, set index name as None.
Method #2: Using pivot() method.
In order to convert a column to row name/index in dataframe, Pandas has a built-in function
Now, let’s say we want
Result to be the rows/index, and columns be
name in our dataframe, to achieve this pandas has provided a method called Pivot. Let us see how it works,
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course