-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REGR: Series repr of object Index with bools and NaN is wrong #32146
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
take |
Not sure if this is related but it seems similar:
>>> import pandas as pd
>>> import numpy as np
>>> s = pd.Series(range(3), index=[True, False, np.nan])
>>> s
True 0
False 1
True 2
dtype: int64 This >>> s.index.value_counts(dropna=False)
True 1
False 1
True 1
dtype: int64 But the correct value is still used "under the hood": >>> s.index.unique()
Index([True, False, nan], dtype='object') |
Yes, so it is not directly related to
|
And this seems to be a regression compared to 0.25, so tagged it as such (and with 1.0.2 milestone) |
And the bug should be somewhere in here:
|
And there, the
(this returns I suppose this is caused by #27335 |
Code Sample, a copy-pastable example if possible
Problem description
As shown in the example, the repr of the value_counts result is apparently wrong when booleans are in the serie. It should report nan as a possible value, instead it maps it to True.
Note that this is limited to series with boolean. A similar example with ints works ok.
Output of
pd.show_versions()
pandas : 1.0.1
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.2.0
Cython : None
pytest : 5.3.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : None
IPython : 7.12.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.5
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : 1.3.13
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: