Closed Els-K closed 5 years ago
I haven't looked at the example, but is this just two's-complement rounding? https://en.wikipedia.org/wiki/Two%27s_complement
This was an intentional change in 0.24.0: https://pandas.pydata.org/pandas-docs/version/0.24.2/whatsnew/v0.24.0.html#datetimelike
Here was the PR with the behavior fix.https://github.com/pandas-dev/pandas/pull/22802
Hi,
this rounding behavior makes sense in many cases, in particular from a statistical point of view. However, at least for my application in time-series/dataframe analysis (created from several measurement devices that are not 100% synchronized, often several month of data, 1-10Hz sampling frequency), it does not, as my formerly unique timestamps get duplicated. Of course, I can easily solve the problem in my case by adding some time-delta that forces rounding up/down, but it took me a while to understand the problem. I think it would be great to have at least some note in the docs to inform about this behavior, or even better, have an option to choose the kind of rounding, depending on one’s needs.
Best regards, Katharina Elsen
Deutsches Zentrum für Luft- und Raumfahrt (DLR) German Aerospace Center Institut für Physik der Atmosphäre (IPA) / Institute of Atmospheric Physics | Oberpfaffenhofen | 82234 Wessling | Germany
Dr. Katharina Elsen Tel. +49 8153 28-1330| Fax +49 8153 28-1841 | katharina.elsen@dlr.demailto:katharina.elsen@dlr.de | www.dlr.de/ipahttp://www.dlr.de/ipa/
Von: Matthew Roeschke [mailto:notifications@github.com] Gesendet: Donnerstag, 12. September 2019 21:01 An: pandas-dev/pandas Cc: Elsen, Katharina Maria; Author Betreff: Re: [pandas-dev/pandas] Series.dt.round fails if fraction is exactly 0.5 (#28408)
This was an intentional change in 0.24.0: https://pandas.pydata.org/pandas-docs/version/0.24.2/whatsnew/v0.24.0.html#datetimelike
Here was the PR with the behavior fix.#22802https://github.com/pandas-dev/pandas/pull/22802
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/pandas-dev/pandas/issues/28408?email_source=notifications&email_token=ANFNXRU3YL2YWYIMNMNOOO3QJKGYRA5CNFSM4IWCWC6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6S5FLQ#issuecomment-530961070, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANFNXRR3TEPHOD4DSNPU4ITQJKGYRANCNFSM4IWCWC6A.
Can you make a pull request updating the docs? Probably in timeseries.rst
On Sep 16, 2019, at 03:18, Els-K notifications@github.com wrote:
Hi,
this rounding behavior makes sense in many cases, in particular from a statistical point of view. However, at least for my application in time-series/dataframe analysis (created from several measurement devices that are not 100% synchronized, often several month of data, 1-10Hz sampling frequency), it does not, as my formerly unique timestamps get duplicated. Of course, I can easily solve the problem in my case by adding some time-delta that forces rounding up/down, but it took me a while to understand the problem. I think it would be great to have at least some note in the docs to inform about this behavior, or even better, have an option to choose the kind of rounding, depending on one’s needs.
Best regards, Katharina Elsen
Deutsches Zentrum für Luft- und Raumfahrt (DLR) German Aerospace Center Institut für Physik der Atmosphäre (IPA) / Institute of Atmospheric Physics | Oberpfaffenhofen | 82234 Wessling | Germany
Dr. Katharina Elsen Tel. +49 8153 28-1330| Fax +49 8153 28-1841 | katharina.elsen@dlr.demailto:katharina.elsen@dlr.de | www.dlr.de/ipahttp://www.dlr.de/ipa/
Von: Matthew Roeschke [mailto:notifications@github.com] Gesendet: Donnerstag, 12. September 2019 21:01 An: pandas-dev/pandas Cc: Elsen, Katharina Maria; Author Betreff: Re: [pandas-dev/pandas] Series.dt.round fails if fraction is exactly 0.5 (#28408)
This was an intentional change in 0.24.0: https://pandas.pydata.org/pandas-docs/version/0.24.2/whatsnew/v0.24.0.html#datetimelike
Here was the PR with the behavior fix.#22802https://github.com/pandas-dev/pandas/pull/22802
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/pandas-dev/pandas/issues/28408?email_source=notifications&email_token=ANFNXRU3YL2YWYIMNMNOOO3QJKGYRA5CNFSM4IWCWC6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6S5FLQ#issuecomment-530961070, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANFNXRR3TEPHOD4DSNPU4ITQJKGYRANCNFSM4IWCWC6A. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Code Sample, a copy-pastable example if possible
Problem description
If the time fraction is exactly 0.5, rounding half up/half down is applied depending on the digit left of it (even/odd). So, '11:59:00.350' would be rounded half up whilst '11:59:00.450' is rounded half down.
Expected Output
Expected output would be either:
or:
Output of
pd.show_versions()