Skip to content
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

Allow tz-aware timstamps in gaps.trim #206

Merged
merged 6 commits into from
Feb 9, 2024

Conversation

qnguyen345
Copy link
Contributor

@qnguyen345 qnguyen345 commented Feb 8, 2024

Updated quality.gaps.trim function for updated versions of Pandas 2.0

  • Closes #xxx
  • Added tests to cover all new or modified code.
  • Clearly documented all new API functions with PEP257 and numpydoc compliant docstrings.
  • Added new API functions to docs/api.rst.
  • Non-API functions clearly documented with docstrings or comments as necessary.
  • Adds description and name entries in the appropriate "what's new" file
    in docs/whatsnew
    for all changes. Includes link to the GitHub Issue with :issue:`num`
    or this Pull Request with :pull:`num`. Includes contributor name
    and/or GitHub username (link with :ghuser:`user`).
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels and Milestone are assigned to the Pull Request and linked Issue.

@kandersolar kandersolar added this to the v0.2.0 milestone Feb 8, 2024
@kandersolar kandersolar added the bug Something isn't working label Feb 8, 2024
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @qnguyen345 for the PR! One question below.

Comment on lines 413 to 416
mask.loc[start.date():end.date()] = True
mask.loc[pd.to_datetime(start.date()).tz_localize(series.index.tz):
pd.to_datetime(end.date()).tz_localize(series.index.tz)] = \
True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return values of start_stop_dates seem to always have timestamps at midnight. With that in mind, do we need to do any conversion like .date() here? Couldn't we just use start and end as-is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right mask.loc[start:end] = True would also works since adding .date() would change start and end from tz-aware to tz-naive, which made the Pandas error. I edited the code and have pushed your suggestion.

@kperrynrel
Copy link
Member

@kandersolar we went through all of the examples and the QA notebooks and this was the only function throwing a pandas error (data shifts module didn't have issues). When this is merged in, we should be good to go with pandas>=2.0.0

@kandersolar kandersolar changed the title Gaps pandas fix Allow tz-aware timstamps in gaps.trim Feb 9, 2024
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @qnguyen345!

@kandersolar kandersolar merged commit 201b495 into pvlib:main Feb 9, 2024
42 checks passed
@qnguyen345 qnguyen345 deleted the gaps_pandas_fix branch August 6, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants