Skip to content

BUG: Timestamp.unit now reflects changes in components after Timestamp.replace #58121

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

Conversation

diogomsmiranda
Copy link

@diogomsmiranda diogomsmiranda commented Apr 2, 2024

The logic behind this is having the Timestamp.unit set as the most precise unit changed on Timestamp.replace if one is more precise than the previous set.

@mroeschke mroeschke requested a review from jbrockmendel April 3, 2024 18:01
@mroeschke mroeschke added Non-Nano datetime64/timedelta64 with non-nanosecond resolution Timestamp pd.Timestamp and associated methods labels Apr 3, 2024
@diogomsmiranda diogomsmiranda force-pushed the reflect-changes-in-components branch 4 times, most recently from c3a4ebf to 5a62136 Compare April 7, 2024 22:20
@diogomsmiranda
Copy link
Author

Hey, I've made the requested changes.

cc @jbrockmendel

@diogomsmiranda
Copy link
Author

diogomsmiranda commented May 10, 2024

@jbrockmendel @mroeschke Hey!! Sorry for the ping but it's been a while since I last heard from you, is this change still of interest?

Let me know If you need anything from me :)

@diogomsmiranda
Copy link
Author

@jbrockmendel I see you made a change on this files recently, does this still work as intended?
I haven't heard from you in a while. Is this still on track to be merged?

@diogomsmiranda
Copy link
Author

Hey @mroeschke after speaking with him it is of my understanding that @jbrockmendel is taking some time mostly-off contributing for pandas, he indicated that you might be able to review this in the meantime? thanks in advance

@diogomsmiranda diogomsmiranda force-pushed the reflect-changes-in-components branch from 765e7ee to 13fdc2a Compare June 19, 2024 14:21
@diogomsmiranda diogomsmiranda requested a review from mroeschke June 19, 2024 14:24
@mroeschke
Copy link
Member

Could you add a test like

ts = pd.Timestamp(year=2020, month=1, day=1, nanosecond=5)
result = ts.replace(nanosecond=0)
assert result.unit == "s"

@diogomsmiranda
Copy link
Author

@mroeschke In fact that logic was not yet implemented, thank you for noticing! I have attempted to solve the issue by registering if a replacement with 0 was made and if so add an extra check to recalculate the replacement resolution. The test now passes successfully.

@diogomsmiranda diogomsmiranda force-pushed the reflect-changes-in-components branch from 5e6c223 to d2c9a04 Compare June 22, 2024 14:34
@diogomsmiranda diogomsmiranda requested a review from mroeschke June 23, 2024 10:54
@diogomsmiranda diogomsmiranda force-pushed the reflect-changes-in-components branch from d2c9a04 to ff9f0f6 Compare June 26, 2024 16:02
@diogomsmiranda diogomsmiranda requested a review from mroeschke June 26, 2024 16:02
@diogomsmiranda
Copy link
Author

@mroeschke Hey, I've added the test cases requested!! Had to change some things in the logic but I believe it's working as intended now.

@diogomsmiranda diogomsmiranda force-pushed the reflect-changes-in-components branch from ff9f0f6 to f2ca887 Compare June 26, 2024 16:17
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution Timestamp pd.Timestamp and associated methods
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Timestamp.unit should reflect changes in components after Timestamp.replace
3 participants