Skip to content
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

ENH: Performance optimization for pd.merge introducing fillna= argument #42683

Closed
anatolix opened this issue Jul 23, 2021 · 2 comments
Closed
Labels
Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Performance Memory or execution speed performance Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@anatolix
Copy link

anatolix commented Jul 23, 2021

Is your feature request related to a problem?

Very often we merge very data sets(100Gb) with 'left'/'right'/'outer' which introduces NAs.
Basically, if we have integer field, we have two options:

  1. Allow pandas autoconvert it to float which could be nan (default behaviour)
  2. Use Int64 type, which is actually quite slow to use it in large datasets spending ages in _PyEval_EvalFrameDefault

Describe the solution you'd like

The obvious option is to use fill value, like -1 for NaN, it currently could be done after 1st or 2nd step, with fillna and conversion to integer type back. It will be quite simple to introduce new parameter inmerge fillna={ "column1":-1, "column2":-1} which do the same task without addition computations.

API breaking implications

By default fillna should be None, which will keep current behaviour.

p.s. the same thing is reasonable for pd.concat

@anatolix anatolix added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 23, 2021
@rhshadrach rhshadrach added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Jul 31, 2021
@mzeitlin11
Copy link
Member

Thanks for looking into this @anatolix! Do you have the profile results or a nice example to run for the Int64 slowness you mention? While the enhancement you propose might be a suitable workaround, seems like the ideal scenario would be to make Int64 as fast as int64 (since the whole point of Int64 is to represent integer data which might include nans)

@mzeitlin11 mzeitlin11 added Performance Memory or execution speed performance and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 5, 2021
@mroeschke
Copy link
Member

Thanks for the issue, but it appears this hasn't gotten traction in a while so closing

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 Performance Memory or execution speed performance Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

4 participants