Skip to content

BUG: Inconsistent .values NA/NaN #61856

Open
@jbrockmendel

Description

@jbrockmendel

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

ser = pd.Series([1, pd.NA], dtype=pd.Float64Dtype())
df = pd.DataFrame({"A": ser, "B": ["foo", "bar"]})

>>> df[["A"]].values[1,0]
np.float64(nan)

>>> df.values[1,0]
<NA>

Issue Description

When another column forces .values to be object dtype we retain pd.NA, otherwise we cast to NaN.
Same behavior with Int64Dtype.

Expected Behavior

This should be consistent.

Installed Versions

Replace this line with the output of pd.show_versions()

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