-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: equal-valued series should work with qcut #47156
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
I believe that when s = pd.Series([1] * 5)
pd.qcut(s, 1, duplicates='drop') =>
That said, I must admit that I don't quite understand the behavior of s = pd.Series([1, 1, 1, 2, 2, 2])
pd.qcut(s, 2, duplicates='drop') =>
but then s = pd.Series([1, 1, 1, 2, 2])
pd.qcut(s, 2, duplicates='drop') =>
Is it joining both bins in the second example? That gives entirely different results for say |
I think where the result is not well defined it maybe should error. my reasoning here is that if
makes sense when the bins are intervals, but the result should probably be consistent with |
Sorry, I'm not quite following you. For both |
yes this mentally makes sense and also means that I believe the implementation however is trying to calculate the boundaries and therefore fails (or produces unexpected results) with non-unique values. from #16328 (comment)
I'm going to close this as a duplicate to avoid having similar discussion in multiple places. |
Pandas version checks
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 main branch of pandas.
Reproducible Example
0 NaN
1 NaN
2 NaN
3 NaN
4 NaN
dtype: category
Categories (0, interval[float64, right]): []
Issue Description
The series in the example fails to produce a partition with just one bin.
Adding one different value to the saries works:
=>
Expected Behavior
A partition with just one bin would be a sensible answer when
duplicates='drop'
is required.Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.9.12.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 22.0.4
setuptools : 60.10.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.9.3
jinja2 : 3.1.2
IPython : 8.3.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : 2.1.1
matplotlib : 3.5.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
snappy : None
sqlalchemy : 1.4.36
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: