ENH: new method Series.struct.assign
to allow adding sub-fields to a struct
#59014
Open
1 of 3 tasks
Labels
Arrow
pyarrow functionality
Enhancement
Needs Discussion
Requires discussion from core team before further action
Feature Type
Adding new functionality to pandas
Changing existing functionality in pandas
Removing existing functionality in pandas
Problem Description
When working with a Series with dtype
pd.ArrowDtype(pa.struct(...))
, it would be nice to have a way to add new sub-fields to the struct.Feature Description
A new method
assign
on theStructAccessor
with similar semantics asDataFrame.assign
but instead of adding a new column to the DataFrame, it adds a new subfield to the struct and returns the struct Series.This could use the
pyarrow.compute.make_struct
function to either add or replace the subfields in the existing struct array.Alternative Solutions
__getitem__
and__setitem__
onStructAccessor
could be a natural way to do this as well, but I'm not sure about adding inplace operations on an accessor object.Additional Context
This would make struct (aka "record" / "nested") columns more useful for data read from BigQuery.
The text was updated successfully, but these errors were encountered: