ENH: Don't remove the ability to expand a Series to a DataFrame by applying a function that returns Series #55134
Labels
Apply
Apply, Aggregate, Transform, Map
Deprecate
Functionality to remove in pandas
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
Being able to expand a Series by applying a function to its cells is very convenient, but in 2.1 in produces a
FutureWarning: Returning a DataFrame from Series.apply when the supplied function returns a Series is deprecated and will be removed in a future version
Feature Description
Right now I can do this:
I tried to get rid of the FutureWarning, but changing the
expand_cell
return value to bepd.Series(data).to_frame()
didn't help, because in such case the result ofapply()
is a Series with each cell containing a DataFrame.I might be missing something, but as of right now the only working solution which doesn't raise a Warning seems be the replacement of the concise
df[column].apply(expand_cell)
with a more uglypd.DataFrame([expand_cell(c) for c in df[column]])
.Alternative Solutions
Keep everything as is, I guess? :)
Additional Context
No response
The text was updated successfully, but these errors were encountered: