October 2019
Beginner to intermediate
674 pages
16h 43m
English
The transpose function in pandas is similar to that of NumPy. It interchanges rows and columns. Let's find the transpose of the following DataFrame:
sales_data.groupby("Category").sum()
The following will be the output:

In the transpose of the DataFrame, the column labels and row indices are swapped:
sales_data.groupby("Category").sum().transpose()
The following will be the output:

T acts as an accessor to the transpose function and can be used as shown:
sales_data.groupby("Category").sum().T ...Read now
Unlock full access