Skip to content

ENH: Add na_value to DataFrame.to_numpy #33820

Closed
@TomAugspurger

Description

@TomAugspurger

Is your feature request related to a problem?

Control the NA value used when converting a DataFrame to an ndarray.

Describe the solution you'd like

Add an na_value argument to DataFrame.to_numpy(). Has the same meaning as na_value in Series.to_numpy, except it applies to all the columns.

Additional context

In [8]: df = pd.DataFrame({"A": pd.array([1, None])})

In [9]: df.to_numpy(na_value=np.nan)

This has come up in a few places (cc @jorisvandenbossche @dsaxton)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions