| [ Web Proxy ] |
| Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.DataFrame.transpose.html | [Back] [Original] |
Section Navigation
Transpose index and columns.
Reflect the DataFrame over its main diagonal by writing rows as columns
and vice-versa. The property T is an accessor to the method
transpose().
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
The transposed DataFrame.
Copyright 2019, Google.
Created using Sphinx 8.1.3.
Built with the PyData Sphinx Theme 0.19.0.
| Web Proxy Viewer | New URL | Original Page |