BUG: replacement works for object but not string dtype · Issue #35977 · pandas-dev/pandas (original) (raw)
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample
import pandas as pd import numpy as np
a = pd.DataFrame({'a': ['a', 'b', 'c'], 'b': ['d', '', '']}, dtype='object') b = pd.DataFrame({'a': ['a', 'b', 'c'], 'b': ['d', '', '']}, dtype='string')
print(a) a.replace(r'^\s*$', pd.NA, regex=True, inplace=True) print(a)
print(b) b.replace(r'^\s*$', pd.NA, regex=True, inplace=True) print(b)
Problem description
replace(r'^\s*$', pd.NA, regex=True, inplace=True) works on object dtype, but not on stringdtype
Expected Output
Same on both replacement
Output of pd.show_versions()
[paste the output of pd.show_versions()
here leaving a blank line after the details tag]