Skip to content

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

Closed
@h-vetinari

Description

@h-vetinari

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions