bigframes.pandas.DataFrame.transpose#

DataFrame.transpose()DataFrame[source]#

Transpose index and columns.

Reflect the DataFrame over its main diagonal by writing rows as columnsand vice-versa. The propertyT is an accessor to the methodtranspose().

All columns must be the same dtype (numerics can be coerced to a common supertype).

Examples:

Square DataFrame with homogeneous dtype

>>>d1={'col1':[1,2],'col2':[3,4]}>>>df1=bpd.DataFrame(data=d1)>>>df1   col1  col20     1     31     2     4[2 rows x 2 columns]
>>>df1_transposed=df1.T# or df1.transpose()>>>df1_transposed      0  1col1  1  2col2  3  4[2 rows x 2 columns]

When the dtype is homogeneous in the original DataFrame, we get atransposed DataFrame with the same dtype:

>>>df1.dtypescol1    Int64col2    Int64dtype: object>>>df1_transposed.dtypes0    Int641    Int64dtype: object
Returns:

The transposed DataFrame.

Return type:

bigframes.pandas.DataFrame

This Page