Skip to content

Boolean string methods on empty Series return object dtype #29624

Closed
@TomAugspurger

Description

@TomAugspurger

Code Sample, a copy-pastable example if possible

In [7]: pd.Series([], dtype=object).str.isalnum()
Out[7]: Series([], dtype: object)

Problem description

On empty series, we return an object-dtype result, rather than bool. I might expect
this to be a boolean dtype to match the non-empty case.

Expected Output

In [14]: pd.Series([], dtype=object).str.isalnum()
Out[14]: Series([], dtype: bool)

Metadata

Metadata

Assignees

No one assigned

    Labels

    StringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions