Skip to content

replace method does't work with string type Series #31644

Closed
@GYHHAHA

Description

@GYHHAHA

Code Sample, a copy-pastable example if possible

>>>pd.Series(['A','B']).replace(r'.','C',regex=True)
0    C
1    C
dtype: object
pd.Series(['A','B']).astype('string').replace(r'.','C',regex=True)
0    A
1    B
dtype: string

Problem description

It seems that replace doesn't work with the string type Series.
Why these two codes return different results?

Metadata

Metadata

Labels

NA - MaskedArraysRelated to pd.NA and nullable extension arraysNeeds TestsUnit test(s) needed to prevent regressionsStringsString extension data type and string datagood first issuereplacereplace method

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions