Subclassing pandas.Index · Issue #15258 · pandas-dev/pandas (original) (raw)

@spencerkclark is working on a custom pandas.Index subclass for xarray (see pydata/xarray#1084) like pandas.DatetimeIndex to handle arrays of netcdftime.datetime objects. This index is primarily intended for use with xarray, but ideally we'd like it to work in pandas Series and DataFrame objects, too.

The subclass will include implementations of at least get_loc, get_slice_bound and get_value (this one should probably be unnecessary, but it's needed for pandas.Series). To minimize fragility, it will not subclass DatetimeIndex but will instead copy some of the relevant code (thank you open source!).

Two questions for other pandas devs:

At a bare minimum, we should probably add some tests to pandas to ensure that a basic subclass works.