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

API/BUG: unnecessary upcasting for df.update #23606

Closed
h-vetinari opened this issue Nov 9, 2018 · 2 comments
Closed

API/BUG: unnecessary upcasting for df.update #23606

h-vetinari opened this issue Nov 9, 2018 · 2 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Nov 9, 2018

I looked through all the open issues with update and dtype in them, but didn't find something - apologies if an issue exists already.

Consider:

>>> import pandas as pd
>>> s = pd.Series([10, 11, 12])
>>> t = pd.Series([61, 63], index=[1, 3])
>>> s.update(t)
>>> s
0    10
1    61
2    12
dtype: int64

So far, so good. Now, for frames:

>>> df = s.to_frame('A')
>>> df.update(t.to_frame('A'))
>>> df
      A
0  10.0
1  61.0
2  12.0

Obviously, the dtype promotion here was neither desired nor necessary (strictly speaking; s and t are both int64), and is simply a by-product of the alignment happening behind the scenes.

@gfyoung gfyoung added Dtype Conversions Unexpected or buggy dtype conversions Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff labels Nov 11, 2018
@gfyoung
Copy link
Member

gfyoung commented Nov 11, 2018

Your issue makes sense to me!

@mroeschke mroeschke added the Bug label May 13, 2020
@mroeschke mroeschke removed the Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff label Jun 23, 2021
@lithomas1
Copy link
Member

Looks fixed on main at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

No branches or pull requests

4 participants