Skip to content

ENH: Select what to return when list is empty in explode #35840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JavierLTPromofarma opened this issue Aug 21, 2020 · 1 comment
Closed

ENH: Select what to return when list is empty in explode #35840

JavierLTPromofarma opened this issue Aug 21, 2020 · 1 comment
Labels
Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@JavierLTPromofarma
Copy link

Is your feature request related to a problem?

I have used explode function over a df that has sometimes an empty list. The empty list return a nan, that raises problems in posteriors processing, because pandas detect them as floats.

Describe the solution you'd like

Explode could have a new argument called return_value_when_empty or something like that (probably a better and/or shorter name) that allows you to define what to return when a particular row has an empty list. For instance, it could be an empty dict, an empty list, a string, integer or whatever.

This way you don't have to use fillna (or more complicated things if fillna doesn't work i.e https://stackoverflow.com/questions/25898888/pandas-replace-all-nan-values-in-dataframe-with-empty-python-dict-objects)

@JavierLTPromofarma JavierLTPromofarma added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 21, 2020
@jreback
Copy link
Contributor

jreback commented Aug 21, 2020

see #34923 and associated PR, better to infer these results and you can simply fill them (or not as desired).

@jreback jreback closed this as completed Aug 21, 2020
@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 21, 2020
@jreback jreback added this to the No action milestone Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants