BUG: replacing a string with None causes an unexpected forward fill · Issue #36984 · 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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Your code here
df = pd.DataFrame(np.zeros((3, 3))) df.iloc[2, 2] = '' df = df.replace('', None) print(df.iloc[2, 2] == '') # prints False print(df.iloc[2, 2] == df.iloc[1, 2]) # prints True
Problem description
[this should explain why the current behaviour is a problem and why the expected output is a better solution]
Expected Output
Replacing a string with a None should introduce a None, not forward fill the previous result.
Output of pd.show_versions()
INSTALLED VERSIONS
commit : db08276
python : 3.6.5.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.3
numpy : 1.19.2
pytz : 2018.9
dateutil : 2.8.1
pip : 20.2
setuptools : 49.2.0
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : 1.8.3
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.13.0
pandas_datareader: None
bs4 : 4.9.0
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.2.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.16
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None