pack_flat

Contents

pack_flat#

pack_flat(df: DataFrame, name: str | None = None, *, on: None | str | list[str] = None) NestedSeries[source]#

Make a structure of lists representation of a “flat” dataframe.

For the input dataframe with repeated indexes, make a pandas.Series, where each original column is replaced by a structure of lists. The dtype of the column is nested_pandas.NestedDtype with the corresponding pyarrow type. The index of the output series is the unique index of the input dataframe. The Series has .nest accessor, see nested_pandas.series.accessor.NestSeriesAccessor() for details.

Parameters:
  • df (pd.DataFrame) – Input dataframe, with repeated indexes.

  • name (str, optional) – Name of the NestedSeries.

  • on (str or list of str, optional) – Column name(s) to join on. If None, the df’s index is used.

Returns:

Output series, with unique indexes.

Return type:

NestedSeries

See also

nested_pandas.series.accessor.NestSeriesAccessor

.nest accessor for the output series.

nested_pandas.series.dtype.NestedDtype

The dtype of the output series.

nested_pandas.series.packer.pack_lists

Pack a dataframe of nested arrays.