-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: cut with labels Tuple[Timestamp, ...] -> wrong number of dimensions #40661
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
Labels
Milestone
Comments
This doesn't seem to raise on master. Maybe could use a test
|
Assign me this issue |
take |
Svanazar
added a commit
to Svanazar/pandas
that referenced
this issue
Oct 2, 2021
4 tasks
jreback
pushed a commit
that referenced
this issue
Oct 3, 2021
gasparitiago
pushed a commit
to gasparitiago/pandas
that referenced
this issue
Oct 9, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Code Sample, a copy-pastable example
Traceback
Problem description
Say you are trying to cut a DataFrame:
How do you build the resulting index? Using either the default intervals provided by the cut function or some temporary identifying labels, build the index using lookups on the input dataframe. Merging runs the risk of dropping columns even with
how="left"
andvalidate="1:1"
. Concatenation has the same problems assuming the indices are matched. There is no simple way to lookup the value of a matching column given the value of another column (afaik) in the same row. The straightforward approach is to convert the dataframe to a dictionary for lookups and that's tedious.Or you can just build the index from the input dataframe and pass it to the cut function via the
labels
keyword. And that's why the current behaviour is a problem and why it should be fixed.Aside
As an aside, the documentation for the
labels
parameter is lacking:It can't accept numpy arrays. It can't accept MultiIndex. It can't accept DataFrame. It can't accept Series, or lists of Series. It can't accept lists of lists. That should be noted. And per my convincing argument above, the list of acceptable types should be expanded.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : f2c8480
python : 3.8.8.final.0
python-bits : 64
OS : CYGWIN_NT-10.0-19041
OS-release : 3.1.7-340.x86_64
Version : 2020-08-22 17:48 UTC
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.2.3
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 41.2.0
Cython : 0.29.22
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.21.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.1
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: