Skip to content

add CFTimeIndex enabled date_range function #2142

Closed
@jhamman

Description

@jhamman

Pandas' date_range function is a fast and flexible way to create DateTimeIndex objects. Now that we have a functioning CFTimeIndex, it would be great to add a version of the date_range function that supports other calendars and dates out of range for Pandas.

Code Sampl and expected output

In [1]: import xarray as xr

In [2]: xr.date_range('2000-02-26', '2000-03-02')
Out[2]:
DatetimeIndex(['2000-02-26', '2000-02-27', '2000-02-28', '2000-02-29',
               '2000-03-01', '2000-03-02'],
              dtype='datetime64[ns]', freq='D')

In [3]: xr.date_range('2000-02-26', '2000-03-02', calendar='noleap')
Out[3]:
CFTimeIndex(['2000-02-26', '2000-02-27', '2000-02-28', '2000-03-01',
               '2000-03-02'],
              dtype='cftime.datetime', freq='D')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions