set_filled_column#
- NestSeriesAccessor.set_filled_column(column: str, value: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) NestedSeries[source]#
Set the column by repeating values and return a new series
The input value array must have as many elements as the Series, each of them will be repeated in the corresponding list.
.nest.set_filled_column(“a”, [1, 2, 3]) will create a nested column “a” with values [[1, 1, …], [2, 2, …], [3, 3, …]].
- Parameters:
column (str) – Name of the field to set. If not present, it will be added.
value (ArrayLike) – Array of values to set. It must have the same length as the series.
- Returns:
The new series with the field set.
- Return type:
Examples
>>> from nested_pandas.datasets.generation import generate_data >>> nf = generate_data(3, 2, seed=1)
>>> nf_filled = nf["nested"].nest.set_filled_column("a", [1,2,3])
>>> # Look at one row of the series >>> nf_filled[0] t flux flux_error band a 0 3.725204 20.445225 1.0 g 1 1 10.776335 67.046751 1.0 r 1