-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: restore timedelta compability for Timedelta components? #9185
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 disagree entirely here. The actual impl of the The new The 'bug' you mentioned is really that the implementers of those libraries are using an implementation detail IMHO. And it wasn't tested. -1 on this |
I agree that the new The alternative approach is to insist that libraries be aware of our API breakage by not subclassing from |
@shoyer we discussed this at length. If you have a useful alternative then I am all ears. We discussed making these attributes singular e.g. I normally don't like breaking from standard implementations. But the timedelta in the standard library is bad and np.timedelta64 is almost worse. I think |
I don't think that is strictly true. XlsxWriter accepts python The issue in #9139, from my point of view, is that I'm not going to argue either way on that. I just wanted to clarify this in relation to XlsxWriter. |
I have to say that I rather agree with @jmcnamara and @shoyer. By implementing In my opinion, we should:
For that last one, @jreback it is true that is was discussed when this new feature was implemented. But it is always possible we later think that there was a possibly better option. And there were some options discussed as a way around this, and I think there is no blame in changing thought about that.
So one option would be to only include the 'extra' attributes in the components attribute, and keep the only the days/seconds/microseconds on the Timedelta itself and have these compatible with datetime.timedelta. |
ok, seems everyone wants exact compatiblity, ok.fine :)
Not a big deal to change, but would need a small doc section. If anyone wants to give a whirl would be appreciated |
With the new
Timedelta
type (see #8184), we introduced behavior that breaks compatibility with the superclasstimedelta
:td.seconds
refers to seconds since the last minute, rather than seconds since the last day (as in the superclass).I think breaking compatibility with the superclass here was a mistake. User code clearly does rely on the old behavior, e.g., as manifested in bugs for exporting datetime columns to Excel: #9139. Moreover, it's likely to remain an issue causing silent bugs, because external libraries are going to continue to use
isinstance
checks to verify that something is adatetime
/timedelta
object. We chose to subclasstimedelta
here, so we really are stuck with full API compatibility.So I think we should make this change in 0.16. It's a breaking change, but 0.15 was already a breaking change in this respect, and in any case I think we should give ourselves some allowance for API changes for new types.
CC @jorisvandenbossche @jreback
The text was updated successfully, but these errors were encountered: