Skip to content

Infer ExtensionDtype based on object #27995

Open
@andrewgsavage

Description

@andrewgsavage

Would it be possible to infer ExtensionDtypes based on the objects inside a list/array that are used to construct a series?

Eg with an array of pint's Quantity objects:

>>> array_of_qty
array([<Quantity(67.0, 'meter')>, <Quantity(61.0, 'meter')>,
       <Quantity(30.0, 'meter')>, ..., <Quantity(293.0, 'meter')>,
       <Quantity(886.0, 'meter')>, <Quantity(165.0, 'meter')>],
      dtype=object)

Could pandas infer the dtype as PintType in this command?:

df.elevation = array_of_qty

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions