-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
comparing time series with index of different units #63466
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?
Conversation
rhshadrach
left a comment
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 for the PR. Please always add tests.
…nges' into pandas-antriksh-changes
|
Hi @rhshadrach , just wanted to confirm what do you mean by add tests. If by that you meant adding more tests for the pytest to check, then i just did that and made a new pr, whose checks are currently running |
|
Hi @rhshadrach, waiting for a review from your side |
rhshadrach
left a comment
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 for the PR!
| try: | ||
| other_values = other._values | ||
| if hasattr(other_values, "as_unit") and hasattr( | ||
| self._values, "equals" | ||
| ): | ||
| return self._values.equals(other_values.as_unit(self_unit)) |
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.
In what cases does this raise?
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.
an example could be if we put two date_ranges to equal(), one with frequency "D" and other being "M", then if this scenario is hit, we safely get False as answer rather then raising a ValueError, due to frequency mismatch.
basically first check if other_values has units we must compare, second check if self can have these compared to it, then simply check and return if they are equal or not
| result = idx1.intersection(idx2) | ||
| expected = date_range("2000-01-01", periods=3, tz=tz).as_unit("ns") | ||
| tm.assert_index_equal(result, expected) | ||
| tm.assert_index_equal(result, expected, exact=False) |
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.
Why does this need to change?
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.
It relaxes the dtype strictness. In the context of datetimes, it stops caring whether the storage is in nanoseconds or microseconds, as long as the dates themselves represent the same point in history.
Uh oh!
There was an error while loading. Please reload this page.