Closed
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
df = pd.DataFrame({'A':["1","","3"]}, dtype="object")
df.where(df!="", np.nan, inplace=True)
df = pd.DataFrame({'A':["1","","3"]}, dtype="string")
df.where(df!="", np.nan, inplace=True)
Issue Description
I am getting different results when using the where method with different data type which are "object" and "string".
Expected Behavior
First, consider the dataframe with "object" and inplace=True
options.
Then, I got a result that I expected.
df = pd.DataFrame({'A':["1","","3"]}, dtype="object")
df.where(df!="", np.nan, inplace=True)
a
0 1
1 NaN
2 3
But, when I changed the dtypes "object" to "string", I got different result as below.
df = pd.DataFrame({'A':["1","","3"]}, dtype="string")
df.where(df!="", np.nan, inplace=True)
A
0 <NA>
1
2 <NA>
Installed Versions
pandas version: 1.3.5 , numpy version: 1.19.5