Skip to content

Commit 4972dfd

Browse files
author
Joe Hamman
authored
expose CFTimeIndex to public API (#2141)
* expose CFTimeIndex to public API * more docs
1 parent 8ef194f commit 4972dfd

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

doc/api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,13 @@ GroupByObjects
522522
core.groupby.DatasetGroupBy.apply
523523
core.groupby.DatasetGroupBy.reduce
524524

525+
Custom Indexes
526+
==============
527+
.. autosummary::
528+
:toctree: generated/
529+
530+
CFTimeIndex
531+
525532
Plotting
526533
========
527534

xarray/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from .conventions import decode_cf, SerializationWarning
2424

25+
from .coding.cftimeindex import CFTimeIndex
26+
2527
try:
2628
from .version import version as __version__
2729
except ImportError: # pragma: no cover

xarray/coding/cftimeindex.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ def assert_all_valid_date_type(data):
135135

136136

137137
class CFTimeIndex(pd.Index):
138+
"""Custom Index for working with CF calendars and dates
139+
140+
All elements of a CFTimeIndex must be cftime.datetime objects.
141+
"""
138142
year = _field_accessor('year', 'The year of the datetime')
139143
month = _field_accessor('month', 'The month of the datetime')
140144
day = _field_accessor('day', 'The days of the datetime')

0 commit comments

Comments
 (0)