-
Notifications
You must be signed in to change notification settings - Fork 145
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
bug fix for account summary to Discord #473
Conversation
My review is in progress 📖 - I will have feedback for you in a few minutes! |
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.
I have reviewed your code and found 2 potential issues. To discuss my individual comments that I have added, tag me in replies using @korbit-ai.
Please react with a 👍 to my comments that you find helpful and a 👎 to those you find unhelpful - this will help me learn and improve as we collaborate.
stats_df["datetime"] = stats_df["datetime"].dt.tz_localize(None) | ||
stats_df["datetime"] = stats_df["datetime"].dt.tz_localize("America/New_York", ambiguous='infer') |
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.
The timezone localization can be simplified by combining the operations into a single line. Instead of localizing to None and then to 'America/New_York', you can directly convert the timezone using dt.tz_convert('America/New_York')
after ensuring the datetime is localized to UTC. This will make the code more concise and maintainable.
if stats_df['datetime'].dt.tz is None: | ||
# If the datetime is timezone-naive, directly localize it to "America/New_York" | ||
stats_df["datetime"] = stats_df["datetime"].dt.tz_localize("America/New_York", ambiguous='infer') |
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.
I noticed that the datetime handling in the stats_df conversion is not optimal. You're first removing the timezone with tz_localize(None)
and then adding it back with tz_localize('America/New_York')
. This can be simplified by using tz_convert('America/New_York')
directly if the datetime is timezone-aware, or tz_localize('America/New_York')
if it is not. Please refactor this to avoid unnecessary steps and potential bugs.
No description provided.