Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

API: .to_numpy() #69

Open
Open
@jreback

Description

@jreback

xref pandas-dev/pandas#14052

currently we have an (implicity) numpy conversion when we access .values of a 1D (Series). This mostly returns a numpy array, though we do return numpy-like objects several dtypes:

  • categorical, we simply return a Categorical object
  • datetime tz/aware, we return a datetime64[ns] array in UTC (losing the tz)

This also has implications when we have a 2D object (DataFrame). we use a type that can safely hold all of the data:

  • int & floats -> floats
  • datetime w/tz -> object array
  • object & anything -> object array

so generally this is ok for 2D in that you preserve as much as possible (though of course you must copy / return heavyweight object array at times).

So need some though on how to make this api look & validate cases.

I would propose .to_numpy() (a function, so we can potentially pass options). and it won't break the current API (which we can preserve I think / provide back-compat). w/o making libpandas jump thru hoops to support the 'old' stuff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions