Skip to content

fillna for np.float64(np.nan) #62771

@randomseed42

Description

@randomseed42

I like pd.Float64Dtype() and other pandas datatypes, but one small glitch found in below minimal case:

import pandas as pd

df = pd.DataFrame([(2, 1), (0, 0), (0, None)], columns=('a', 'b'))
df = df.astype(pd.Float64Dtype())

print(df['b'] / df['a'])
# 0     0.5
# 1     NaN
# 2    <NA>
# dtype: Float64

print((df['b'] / df['a']).fillna(0))
# 0    0.5
# 1    NaN
# 2    0.0
# dtype: Float64

print((df['b'] / df['a']).loc[1])
# np.float64(nan)

Is there any plan to make fillna adapt to np.float64(np.nan)? Or make sure 0 / 0 in pd.Float64Dtype() can return pd.NA rather than np.float64(np.nan)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    PDEP missing valuesIssues that would be addressed by the Ice Cream Agreement from the Aug 2023 sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions