| [ Web Proxy ] |
| Viewing: https://dataframes.bigquery.dev/reference/api/bigframes.pandas.DataFrame.explode.html | [Back] [Original] |
Section Navigation
Transform each element of an array to a row, replicating index values.
Examples:
>>> df = bpd.DataFrame({'A': [[0, 1, 2], [], [], [3, 4]],
... 'B': 1,
... 'C': [['a', 'b', 'c'], np.nan, [], ['d', 'e']]})
>>> df.explode('A')
A B C
0 0 1 ['a' 'b' 'c']
0 1 1 ['a' 'b' 'c']
0 2 1 ['a' 'b' 'c']
1 <NA> 1 []
2 <NA> 1 []
3 3 1 ['d' 'e']
3 4 1 ['d' 'e']
[7 rows x 3 columns]
>>> df.explode(list('AC'))
A B C
0 0 1 a
0 1 1 b
0 2 1 c
1 <NA> 1 <NA>
2 <NA> 1 <NA>
3 3 1 d
3 4 1 e
[7 rows x 3 columns]
column (str, Sequence[str]) Column(s) to explode. For multiple columns, specify a non-empty list with each element be str or tuple, and all specified columns their list-like data on same row of the frame must have matching length.
ignore_index (bool, default False) If True, the resulting index will be labeled 0, 1, , n - 1.
Exploded lists to rows of the subset columns; index will be duplicated for these rows.
If columns of the frame are not unique. * If specified columns to explode is empty list. * If specified columns to explode have not matching count of elements rowwise in the frame.
KeyError If incorrect column names are provided
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 |