Skip to content

API: Use object dtype for empty Series #17261

Closed
@TomAugspurger

Description

@TomAugspurger

Currently an empty Series has a float dtype:

In [15]: pd.Series().dtype
Out[15]: dtype('float64')

This is consistent with NumPy, but inconsistent with the rest of pandas:

In [18]: pd.Index([]).dtype
Out[18]: dtype('O')

In [19]: pd.DataFrame(columns=['A']).dtypes
Out[19]:
A    object
dtype: object

I think it's best to just make all our containers treat empty as object dtype, unless explicitly told otherwise (excluding specialized containers like Int64Index).

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignConstructorsSeries/DataFrame/Index/pd.array ConstructorsDtype ConversionsUnexpected or buggy dtype conversions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions