-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series has no attribute "reshape" after adding a new category in df #35731
New issue
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
Comments
Thanks for the report @chen-bowen, this is broken on master as well. Worked on 1.0.5 so seems to be a regression (below is a slightly smaller reproducer, evidently fillna need not actually do anything to cause isnull to fail): In [1]: import pandas as pd
...:
...: print(pd.__version__)
...:
...: df = pd.DataFrame(
...: {
...: "a": pd.Series([1, 2, 3], dtype="category")
...: }
...: )
...: df["a"].fillna(1, inplace=True)
...: df.isnull()
...:
1.0.5
Out[1]:
a
0 False
1 False
2 False |
this is using chained inplace |
Good catch thanks @jreback |
regression from #35271, see also #33457 cc @jorisvandenbossche 6302f7b is the first bad commit
|
It looks like following the |
This is fixed by #35417, though that doesnt yet have a test for this. |
The bad commit is itself reverting another commit, which means there should be another change that caused the revert to cause this regression ..;) Anyway, #35417 might be fixing this, but I don't think this bug in itself is tied to the whole "setitem should create new array" discussion. |
It's So this was actually caused by #33028, which changed -> fix #35936 |
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
Problem description
We are trying to add the new fillna as a new category in the dataframe, but it fails when we are trying to use
df.isnull()
In this case we are pretty much blocked from using df.isull().sum() functionality. Running the above snippet will get us the attribute errorAttributeError: 'Series' object has no attribute 'reshape'
Full stack trace is shown below.
Expected Output
a 0
b 0
c 1
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : d9fff27
python : 3.7.0.final.0
python-bits : 64
OS : Darwin
OS-release : 19.6.0
Version : Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/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.0
numpy : 1.19.0
pytz : 2020.1
dateutil : 2.8.1
pip : 18.1
setuptools : 47.3.1
Cython : None
pytest : 5.4.3
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : 1.3.13
tables : None
tabulate : 0.8.7
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: