bigframes.pandas.DataFrame.transpose#
- DataFrame.transpose() DataFrame[source]#
Transpose index and columns.
Reflect the DataFrame over its main diagonal by writing rows as columns and vice-versa. The property
Tis 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 col2 0 1 3 1 2 4 [2 rows x 2 columns]
>>> df1_transposed = df1.T # or df1.transpose() >>> df1_transposed 0 1 col1 1 2 col2 3 4 [2 rows x 2 columns]
When the dtype is homogeneous in the original DataFrame, we get a transposed DataFrame with the same dtype:
>>> df1.dtypes col1 Int64 col2 Int64 dtype: object >>> df1_transposed.dtypes 0 Int64 1 Int64 dtype: object
- Returns:
The transposed DataFrame.
- Return type: