-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
DOC: Different behaviour with respect to Series.all
docs when NA
values are present
#36692
Comments
To me it seems like the output is correct here and the docs should be updated |
Series.all
docs when NA
values are presentSeries.all
docs when NA
values are present
Indeed, the behaviour for nullable dtypes is as expected, so the docs need an update. The complicating factor, however, is that the current explanation is correct if you have NaN missing data, but the behaviour is thus different with NA missing data. |
It seems to me that we need to explicitly describe the differences in behavior due to missing values.
|
Hi! I was going to open an issue for this but I just noticed this one already existed although is marked as a doc update. I am not sure this is only an issue with documentation since this shows undefined behaviour depending on the case. I noticed this issue when testing that a model produces a column with a given value. When the model registers the result it converts a given column to StringDType. This is a toy example doing something similar to the test. dd = pd.DataFrame({"a": [pd.NA, pd.NA]}, dtype=pd.StringDtype())
dd["b"] = dd["a"] == "hi"
dd["b"]
# 0 <NA>
# 1 <NA>
# Name: b, dtype: boolean At this point I was surprised because In any case, I was thinking that ok, if it returns We could pass dd = pd.DataFrame({"a": [pd.NA, pd.NA]}, dtype=pd.StringDtype())
dd["b"] = dd["a"] == "hi"
# This will be executed but it will pass even though there is no single value set to "hi"
assert dd["b"].all()
# This will raise an exception because we cannot assert over `pd.NA`
assert dd["b"].all(skipna=False) I would say this is a very unexpected behaviour of the This behaviour goes away of there is at least one value that is not NA. dd = pd.DataFrame({"a": [pd.NA, pd.NA, "Value"]}, dtype=pd.StringDtype())
dd["b"] = dd["a"] == "hi"
dd["b"].all()
# False |
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
The documentation says:
But looks like a
pd.NA
value is being returned instead.Expected Output
The expected behavior is the result of
all
should beTrue
if we go by the docs or if this was a conscious design decision to returnNA
as scalar we should be updating the docs to reflect the same.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d332
python : 3.7.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-48-generic
Version : #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.2
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.6.0.post20200917
Cython : 0.29.21
pytest : 6.0.2
hypothesis : 5.28.0
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 0.8.2
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 1.0.1
pytables : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.51.2
The text was updated successfully, but these errors were encountered: