-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Pandas should accept ISO 8601 duration #11375
Comments
not sure what you are intending here. The offsets are usually what you use for things like this. As they handle days/month/year counting propertly. OTOH, |
This issue is just an enhancement request to have a Pandas method to parse ISO 8601 duration strings We could have for example:
(or something similar) |
This is pretty trivial actually. Just need to add a bit to the unit map (e.g. accept DT for days), the P and Y as well.
want to do a pull-request? |
I don't feel very confortable with regex |
its not a regext (anymore). Its all in cython see here |
Sorry I don't know cython (maybe one day I will!) Moreover I don't understand how you will be able to add a
raises
|
you wouldn't add a an offset is a more flexible as it knows its frequency and such. what you are asking is for an extension of the |
Why not constructing in such a case a DateOffset using
we can use years with Timedelta
raises
but that's probably a misunderstanding from my side. When I add a 1 month duration to a date I don't want to add (necessarily) 30 days. |
@femtotrader exactly, this why for your usecase you almost certainly want to use a (and that's why I didn't implement years/months on a Timedelta as they are actually not very important BECAUSE they are not fixed intervals). notice that days,hours,seconds....etc are fixed intervals. |
@jreback If I read the explanation of the ISO 8601, I think what they describe as durations, should be considered as DateOffsets in pandas-world, and not timedelta's |
to say, I don't think it makes sense to support it in the pd.Timedelta parsing |
@jorisvandenbossche yep. We don't support parsing into offsets at all (except for single ones). So this would be a major undertaking, and IMHO not that beneficial). |
ISO 8601:2004(E) (Third edition 2004-12-01) can be found here http://dotat.at/tmp/ISO_8601-2004_E.pdf |
It probably wouldn't be so bad to support something like I guess then all the other offsets would inherit that method though. Seems like it may have been to have something like an |
Hello,
ISO 8601 defines duration.
https://en.wikipedia.org/wiki/ISO_8601#Durations
see also usage in XML Schema http://www.w3.org/TR/xmlschema-2/#d0e11648
Duration can't be defined as
timedelta
(ortimedelta64
) becauseIt will be nice if Pandas could accept ISO 8601 duration.
We should probably use
pd.tseries.offsets.DateOffset
likeKind regards
The text was updated successfully, but these errors were encountered: