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

Return slices when possible from CFTimeIndex.get_loc() #2569

Merged
merged 1 commit into from
Nov 24, 2018

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Nov 24, 2018

This code, adapted from pandas.DatetimeIndex, makes string indexing with CFTimeIndex work in a pandas.MultiIndex.

  • Tests added (for all bug fixes or enhancements)
  • Fully documented, including whats-new.rst for all changes and api.rst for new API (remove if this change should not be visible to users, e.g., if it is an internal clean-up, or if this is part of a larger project that will be documented later)

CC @spencerkclark for review

This makes string indexing usable in a pandas.MultiIndex.
@pep8speaks
Copy link

Hello @shoyer! Thanks for submitting the PR.

Copy link
Member

@spencerkclark spencerkclark left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks! I appreciate the improvements to the error/warning handling as well.

@@ -758,7 +758,7 @@ def test_to_datetimeindex(calendar, unsafe):
with pytest.warns(RuntimeWarning, match='non-standard'):
result = index.to_datetimeindex()
else:
result = index.to_datetimeindex()
result = index.to_datetimeindex(unsafe=unsafe)
Copy link
Member

Choose a reason for hiding this comment

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

Oops good catch

@shoyer shoyer merged commit 9d572a5 into pydata:master Nov 24, 2018
@shoyer shoyer deleted the cftime-get_loc-slice branch November 24, 2018 20:26
dcherian pushed a commit to yohai/xarray that referenced this pull request Dec 16, 2018
* upstream/master:
  Feature: N-dimensional auto_combine (pydata#2553)
  Support HighLevelGraphs (pydata#2603)
  Bump cftime version in doc environment (pydata#2604)
  use keep_attrs in binary operations II (pydata#2590)
  Temporarily mark dask-dev build as an allowed failure (pydata#2602)
  Fix wrong error message in interp() (pydata#2598)
  Add dayofyear and dayofweek accessors (pydata#2599)
  Fix h5netcdf saving scalars with filters or chunks (pydata#2591)
  Minor update to PR template (pydata#2596)
  Zarr consolidated (pydata#2559)
  fix examples (pydata#2581)
  Fix typo (pydata#2578)
  Concat docstring typo (pydata#2577)
  DOC: remove example using Dataset.T (pydata#2572)
  python setup.py test now works by default (pydata#2573)
  Return slices when possible from CFTimeIndex.get_loc() (pydata#2569)
  DOC: fix computation.rst (pydata#2567)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants