| [ Web Proxy ] |
| Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.DataFrame.stack.html | [Back] [Original] |
Section Navigation
Stack the prescribed level(s) from columns to index.
Return a reshaped DataFrame or Series having a multi-level index with one or more new inner-most levels compared to the current DataFrame. The new inner-most levels are created by pivoting the columns of the current dataframe:
if the columns have a single level, the output is a Series;
level(s) is (are) taken from the prescribed level(s) and the output is a DataFrame.
Note
BigQuery DataFrames does not support stack operations that would combine columns of different dtypes.
Examples:
>>> df = bpd.DataFrame({'A': [1, 3], 'B': [2, 4]}, index=['foo', 'bar'])
>>> df
A B
foo 1 2
bar 3 4
[2 rows x 2 columns]
>>> df.stack()
foo A 1
B 2
bar A 3
B 4
dtype: Int64
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 |