You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pandas as pd
print(pd.version)
1.1.1
s1 = pd.Series(['a','b'], dtype='string')
s2 = pd.Series(['a','b'], dtype='object')
s1.replace(r'[a]',pd.NA,regex=True)
0 a
1 b
dtype: string
s2.replace(r'[a]',pd.NA,regex=True)
0
1 b
dtype: object
Hi, it seems that regex doesn't function well for the replace method on string dtype, but normal on object dtype.
Besides, I also find setting pd.NA as repl of str.replace method will raise error, both on string and object.
Yet I think it may be better not to raise this error because the pd.NA indeed could be a missing string value.
pd.Series(['a','b'],dtype='string').str.replace('a',pd.NA)
TypeError: repl must be a string or callable
pd.Series(['a','b'],dtype='object').str.replace('a',pd.NA)
TypeError: repl must be a string or callable
Thanks!
The text was updated successfully, but these errors were encountered:
Hi, it seems that regex doesn't function well for the replace method on string dtype, but normal on object dtype.
Besides, I also find setting pd.NA as repl of str.replace method will raise error, both on string and object.
Yet I think it may be better not to raise this error because the pd.NA indeed could be a missing string value.
Thanks!
The text was updated successfully, but these errors were encountered: