-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
ENH: clarify error message when multiplying bool times Timedelta #63139
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
base: main
Are you sure you want to change the base?
ENH: clarify error message when multiplying bool times Timedelta #63139
Conversation
|
This is t already disallowed? |
@jbrockmendel, thank you for taking a look at this PR. Yes, it's correct, it is disallowed. I thought we wanted to improve the error message. Did I get your comment #62316 (comment) wrong? Maybe I should rename my PR to "ENH: clarify error message …" Update: renamed it |
pandas/_libs/tslibs/timedeltas.pyx
Outdated
| # GH#62316 | ||
| raise TypeError( | ||
| "Cannot multiply Timedelta by bools. " | ||
| "Explicitly cast to integers instead." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool and integer singular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I've changed it to singular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool and integer singular look better to me too, but I found that in pandas we use both the singular and the plural and sometimes we mix them:
pandas/pandas/core/arrays/timedeltas.py
Lines 481 to 482 in 7bf6660
| f"Cannot multiply '{self.dtype}' by bool, explicitly cast to " | |
| "integers instead" |
|
can you add a test |
|
BTW there are a few issues with the "Numeric Operations" label and "MultiIndex" label about silent alignment on arithmetic between Series/Frame with non-aligned MultiIndexes. While looking at them the other day I thought that might be a good topic for you to tackle. |
Done |
Sorry, I did not find the issues you mean. I found these two issues (#60498, #61009) which could be related, but they are already closed. Could you please be more specific? |
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.