We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 master branch of pandas.
import pandas as pd df1 = pd.DataFrame(pd.NA, index=[0, 1], columns=['A', 'A', 'B']) df1.fillna({'A': 0}) df2 = pd.DataFrame(pd.NA, index=[0, 1], columns=['A', 'A']) df2.fillna({'A': 0})
For dataframes with duplicate column names .fillna fails to fill missing values, if a dict is passed as the value parameter
.fillna
dict
value
df1
SettingWithCopyWarning
df2
Expecting missing values in columns of the same name to be filled according to the parsed dict.
commit : 5f648bf python : 3.8.8.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.18362 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : Danish_Denmark.1252 pandas : 1.3.2 numpy : 1.21.2 pytz : 2021.1 dateutil : 2.8.2 pip : 20.2.3 setuptools : 49.2.1 Cython : None pytest : 6.2.4 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 2.11.3 IPython : None pandas_datareader: None bs4 : None bottleneck : None fsspec : 2021.08.1 fastparquet : None gcsfs : None matplotlib : None numexpr : None odfpy : None openpyxl : 3.0.7 pandas_gbq : None pyarrow : 3.0.0 pyxlsb : None s3fs : None scipy : 1.7.1 sqlalchemy : 1.3.23 tables : None tabulate : 0.8.9 xarray : None xlrd : None xlwt : None numba : None
The text was updated successfully, but these errors were encountered:
This is actually raising a SettingWithCopyWarning, probably the reason for this
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
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 master branch of pandas.
Reproducible Example
Issue Description
For dataframes with duplicate column names
.fillna
fails to fill missing values, if adict
is passed as thevalue
parameterdf1
). When multiple, but not all, columns share a name, theSettingWithCopyWarning
is thrown.df2
). When all column names are identical, no error is thrown, nor is missing values replaced.Expected Behavior
Expecting missing values in columns of the same name to be filled according to the parsed
dict
.Installed Versions
INSTALLED VERSIONS
commit : 5f648bf
python : 3.8.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.18362
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Danish_Denmark.1252
pandas : 1.3.2
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 20.2.3
setuptools : 49.2.1
Cython : None
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 2021.08.1
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 3.0.0
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : 1.3.23
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: