-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CFTimeIndex Resampling #2593
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
Merged
Merged
CFTimeIndex Resampling #2593
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
daa3a71
First implementation of resampling for CFTimeIndex.
jwenfai f9f3347
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai 0950505
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai 89f418a
First implementation of resampling for CFTimeIndex, cleaned.
jwenfai 39c9d11
First implementation of resampling for CFTimeIndex.
jwenfai 073b8e0
First implementation of resampling for CFTimeIndex,
jwenfai 193c4c4
First implementation of resampling for CFTimeIndex, test file written.
jwenfai 2c97738
First implementation of resampling for CFTimeIndex, test file written…
jwenfai 9993ed9
First implementation of resampling for CFTimeIndex, test file written…
jwenfai f01745c
First implementation of resampling for CFTimeIndex, test file written…
jwenfai ffbf265
First implementation of resampling for CFTimeIndex, test file written…
jwenfai e64fedb
Merge pull request #1 from jwenfai/resample-v2-clean
jwenfai 2850dd5
Docstrings for resample_cftime.py written. Upsample still not fixed.
jwenfai 770b778
Fixed PEP8 and test parametrization.
jwenfai 181e82c
PEP8
Zeitsperre 5a41ee2
Merge pull request #3 from Ouranosinc/PEP8
Zeitsperre 6b948c5
Test file fixes and other optimizations (2018-12-16 @spencerclark and…
jwenfai 97c0948
Merge pull request #1 from Ouranosinc/master
jwenfai 63d25ab
Merge remote-tracking branch 'origin/resample-v2-clean' into resample…
jwenfai 05af869
Test file fixes and other optimizations (2018-12-16 @spencerclark and…
jwenfai 85f1a84
Merge branch 'resample-v2-upsample' into resample-v2-clean
jwenfai 2e8ced3
Merge pull request #4 from jwenfai/resample-v2-clean
Zeitsperre 4317c69
Merge branch 'master' into master
jwenfai e7deeb2
Merge pull request #2 from Ouranosinc/master
jwenfai f9ac1a1
Merge pull request #3 from Ouranosinc/master
jwenfai 8505ca9
_get_range_edges logic changed to emulate latest version of pandas.
jwenfai a495c2d
Simplified resampling logic (errors persist). Pre-cleaning.
jwenfai ad65ef0
Simplified resampling logic (error persists). Cleaned.
jwenfai 5775e11
Simplified resampling logic (error persists). Fixed first_items.dropn…
jwenfai e1902fe
Simplified resampling logic (error persists). Logic slightly altered …
jwenfai f82500c
Simplified resampling logic (error persists). Logic slightly altered …
jwenfai 80914e0
Merge pull request #5 from jwenfai/resample-v2-upsample
jwenfai 1b3f41a
Simplified resampling logic (error persists). Cleaned. Merged with la…
jwenfai bc95f55
Precise cftime arithmetic. Reduced overall test time. Added test for …
jwenfai 9fa4d51
Merge remote-tracking branch 'origin/master'
jwenfai 5227480
Merge pull request #6 from jwenfai/master
jwenfai 77bb2aa
Added default values for closed and label args of resample function i…
jwenfai be2e657
Merge pull request #7 from jwenfai/master
jwenfai a18161d
Added back replace['dayofwk'] = -1 to cftime_offsets.py and cftimeind…
jwenfai 9582fbf
Merge pull request #8 from jwenfai/master
jwenfai 5737546
Optimizations as per https://github.com/pydata/xarray/pull/2593/#pull…
jwenfai 3268fc4
Merge pull request #9 from jwenfai/master
jwenfai 6f38935
Simple test for non-standard calendars added and documentation updated.
jwenfai e7986c5
Simple test for non-standard calendars added and documentation updated.
jwenfai c64265f
Merge pull request #10 from jwenfai/master
jwenfai 71f98db
Merge branch 'master' into master
jwenfai ec4e460
Added loffset support to CFTimeIndex resampling. Better adherence to …
jwenfai 47b0eaa
Added loffset support to CFTimeIndex resampling. Better adherence to …
jwenfai f2ecaf6
Merge pull request #11 from jwenfai/master
jwenfai cd266c2
Support datetime.timedelta objects for loffset. Improved test coverage.
jwenfai 41783cb
Merge pull request #12 from jwenfai/master
jwenfai 5435910
Removed support for Python 2 compatibility.
jwenfai 35b40fb
Merge pull request #13 from jwenfai/master
jwenfai 814a04d
Updated pandas minversion to 0.24 as 0.24 is officially out.
jwenfai 2a9402e
Merge branch 'pydata-master'
jwenfai 505a0fa
Removed Python 2 support from test_cftimeindex_resample.py.
jwenfai 9fbb016
Merge branch 'master' into master
jwenfai 0820c3b
Merge pull request #14 from jwenfai/master
jwenfai 89bc708
Moved full_index and first_items generation logic to a helper functio…
jwenfai 31ccebf
Merge remote-tracking branch 'origin/master'
jwenfai 8ac6f76
Merge pull request #15 from jwenfai/master
jwenfai 8dbee52
Merge branch 'master' into master
shoyer afad30d
In groupby.py, moved s to _get_index_and_items helper function.
jwenfai 1381dab
Removed redundant code from test_formatting.py due to bad merge.
jwenfai 6074548
Merge pull request #16 from jwenfai/master
jwenfai 1010264
Merge branch 'master' into master
jwenfai 6c4b609
Merge branch 'pydata-master'
jwenfai 59f1f94
Removed redundant test and simplify code now that dropna is implemented.
jwenfai db62a96
Merge branch 'master' into master
jwenfai 6edb45a
Merge pull request #17 from jwenfai/master
jwenfai f7f2c38
delete unnecessary test
shoyer ef68960
eliminate some repetition
shoyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,12 +258,8 @@ def __init__(self, obj, group, squeeze=False, grouper=None, bins=None, | |
if not index.is_monotonic: | ||
# TODO: sort instead of raising an error | ||
raise ValueError('index must be monotonic for resampling') | ||
s = pd.Series(np.arange(index.size), index) | ||
first_items = s.groupby(grouper).first() | ||
_apply_loffset(grouper, first_items) | ||
full_index = first_items.index | ||
if first_items.isnull().any(): | ||
first_items = first_items.dropna() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
full_index, first_items = self._get_index_and_items( | ||
index, grouper) | ||
sbins = first_items.values.astype(np.int64) | ||
group_indices = ([slice(i, j) | ||
for i, j in zip(sbins[:-1], sbins[1:])] + | ||
|
@@ -310,6 +306,19 @@ def __len__(self): | |
def __iter__(self): | ||
return zip(self._unique_coord.values, self._iter_grouped()) | ||
|
||
def _get_index_and_items(self, index, grouper): | ||
from .resample_cftime import CFTimeGrouper | ||
s = pd.Series(np.arange(index.size), index) | ||
if isinstance(grouper, CFTimeGrouper): | ||
first_items = grouper.first_items(index) | ||
else: | ||
first_items = s.groupby(grouper).first() | ||
_apply_loffset(grouper, first_items) | ||
full_index = first_items.index | ||
if first_items.isnull().any(): | ||
first_items = first_items.dropna() | ||
return full_index, first_items | ||
|
||
def _iter_grouped(self): | ||
"""Iterate over each element in this group""" | ||
for indices in self._group_indices: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 example below is not super-relevant now. Maybe delete:
as well as the line that calls
resample
at the end of the code block?