Skip to content

BUG: Interpolate should be more careful with dtypes #6290

Closed
@TomAugspurger

Description

@TomAugspurger

Originally reported as a comment in #6281 Reposting the example from there:

If you start out with a DataFrame like

In [14]: df = DataFrame({'A': [1, 2, np.nan, 4, 5, np.nan, 7],
   ....:                 'C': [1, 2, 3, 5, 8, 13, 21]})

In [15]: df.dtypes
Out[15]: 
A    float64
C      int64
dtype: object

So one float, one int, with no NaNs in the int. We apply the interpolation method to each block, so it gets applied to the int block/column. The interpolation will generally return a float dtype.

In [18]: df.interpolate(method='cubic', downcast=None).dtypes
Out[18]: 
A    float64
C    float64
dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsDtype ConversionsUnexpected or buggy dtype conversionsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions