# xarray.CFTimeIndex

### *class* xarray.CFTimeIndex(data, name=None, \*\*kwargs)[[source]](https://github.com/pydata/xarray/blob/main/xarray/coding/cftimeindex.py#L229-L806)

Custom Index for working with CF calendars and dates

All elements of a CFTimeIndex must be cftime.datetime objects.

* **Parameters:**
  * **data** ([array](https://numpy.org/doc/stable/glossary.html#term-array) or [`CFTimeIndex`](#xarray.CFTimeIndex)) – Sequence of cftime.datetime objects to use in index
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str), *default*: [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Name of the resulting index

#### SEE ALSO
[`date_range`](xarray.date_range.html.md#xarray.date_range)

#### \_\_init_\_()

### Methods

| [`__init__`](#xarray.CFTimeIndex.__init__)()                                                                               |                                                                                                                                      |
|-------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| [`all`](xarray.CFTimeIndex.all.html.md#xarray.CFTimeIndex.all)(\*args, \*\*kwargs)                                           | Return whether all elements are Truthy.                                                                                              |
| [`any`](xarray.CFTimeIndex.any.html.md#xarray.CFTimeIndex.any)(\*args, \*\*kwargs)                                           | Return whether any element is Truthy.                                                                                                |
| [`append`](xarray.CFTimeIndex.append.html.md#xarray.CFTimeIndex.append)(other)                                                  | Append a collection of Index options together.                                                                                       |
| [`argmax`](xarray.CFTimeIndex.argmax.html.md#xarray.CFTimeIndex.argmax)([axis, skipna])                                         | Return int position of the largest value in the Index.                                                                               |
| [`argmin`](xarray.CFTimeIndex.argmin.html.md#xarray.CFTimeIndex.argmin)([axis, skipna])                                         | Return int position of the smallest value in the Index.                                                                              |
| [`argsort`](xarray.CFTimeIndex.argsort.html.md#xarray.CFTimeIndex.argsort)(\*args, \*\*kwargs)                                   | Return the integer indices that would sort the index.                                                                                |
| [`asof`](xarray.CFTimeIndex.asof.html.md#xarray.CFTimeIndex.asof)(label)                                                      | Return the label from the index, or, if not present, the previous one.                                                               |
| [`asof_locs`](xarray.CFTimeIndex.asof_locs.html.md#xarray.CFTimeIndex.asof_locs)(where, mask)                                      | Return the locations (indices) of labels in the index.                                                                               |
| [`astype`](xarray.CFTimeIndex.astype.html.md#xarray.CFTimeIndex.astype)(dtype[, copy])                                          | Create an Index with values cast to dtypes.                                                                                          |
| [`ceil`](xarray.CFTimeIndex.ceil.html.md#xarray.CFTimeIndex.ceil)(freq)                                                       | Round dates up to fixed frequency.                                                                                                   |
| [`contains`](xarray.CFTimeIndex.contains.html.md#xarray.CFTimeIndex.contains)(key)                                                | Needed for .loc based partial-string indexing                                                                                        |
| [`copy`](xarray.CFTimeIndex.copy.html.md#xarray.CFTimeIndex.copy)([name, deep])                                               | Make a copy of this object.                                                                                                          |
| [`delete`](xarray.CFTimeIndex.delete.html.md#xarray.CFTimeIndex.delete)(loc)                                                    | Make new Index with passed location(-s) deleted.                                                                                     |
| `diff`([periods])                                                                                                                         | Computes the difference between consecutive values in the Index object.                                                              |
| [`difference`](xarray.CFTimeIndex.difference.html.md#xarray.CFTimeIndex.difference)(other[, sort])                                  | Return a new Index with elements of index not in other.                                                                              |
| [`drop`](xarray.CFTimeIndex.drop.html.md#xarray.CFTimeIndex.drop)(labels[, errors])                                           | Make new Index with passed list of labels deleted.                                                                                   |
| [`drop_duplicates`](xarray.CFTimeIndex.drop_duplicates.html.md#xarray.CFTimeIndex.drop_duplicates)(\*[, keep])                           | Return Index with duplicate values removed.                                                                                          |
| [`droplevel`](xarray.CFTimeIndex.droplevel.html.md#xarray.CFTimeIndex.droplevel)([level])                                          | Return index with requested level(s) removed.                                                                                        |
| [`dropna`](xarray.CFTimeIndex.dropna.html.md#xarray.CFTimeIndex.dropna)([how])                                                  | Return Index without NA/NaN values.                                                                                                  |
| [`duplicated`](xarray.CFTimeIndex.duplicated.html.md#xarray.CFTimeIndex.duplicated)([keep])                                         | Indicate duplicate index values.                                                                                                     |
| [`equals`](xarray.CFTimeIndex.equals.html.md#xarray.CFTimeIndex.equals)(other)                                                  | Determine if two Index object are equal.                                                                                             |
| [`factorize`](xarray.CFTimeIndex.factorize.html.md#xarray.CFTimeIndex.factorize)([sort, use_na_sentinel])                          | Encode the object as an enumerated type or categorical variable.                                                                     |
| [`fillna`](xarray.CFTimeIndex.fillna.html.md#xarray.CFTimeIndex.fillna)(value)                                                  | Fill NA/NaN values with the specified value.                                                                                         |
| [`floor`](xarray.CFTimeIndex.floor.html.md#xarray.CFTimeIndex.floor)(freq)                                                     | Round dates down to fixed frequency.                                                                                                 |
| [`get_indexer`](xarray.CFTimeIndex.get_indexer.html.md#xarray.CFTimeIndex.get_indexer)(target[, method, limit, tolerance])           | Compute indexer and mask for new index given the current index.                                                                      |
| [`get_indexer_for`](xarray.CFTimeIndex.get_indexer_for.html.md#xarray.CFTimeIndex.get_indexer_for)(target)                               | Guaranteed return of an indexer even when non-unique.                                                                                |
| [`get_indexer_non_unique`](xarray.CFTimeIndex.get_indexer_non_unique.html.md#xarray.CFTimeIndex.get_indexer_non_unique)(target)                 | Compute indexer and mask for new index given the current index.                                                                      |
| [`get_level_values`](xarray.CFTimeIndex.get_level_values.html.md#xarray.CFTimeIndex.get_level_values)(level)                              | Return an Index of values for requested level.                                                                                       |
| [`get_loc`](xarray.CFTimeIndex.get_loc.html.md#xarray.CFTimeIndex.get_loc)(key)                                                  | Adapted from pandas.tseries.index.DatetimeIndex.get_loc                                                                              |
| [`get_slice_bound`](xarray.CFTimeIndex.get_slice_bound.html.md#xarray.CFTimeIndex.get_slice_bound)(label, side)                          | Calculate slice bound that corresponds to given label.                                                                               |
| [`get_value`](xarray.CFTimeIndex.get_value.html.md#xarray.CFTimeIndex.get_value)(series, key)                                      | Adapted from pandas.tseries.index.DatetimeIndex.get_value                                                                            |
| [`groupby`](xarray.CFTimeIndex.groupby.html.md#xarray.CFTimeIndex.groupby)(values)                                               | Group the index labels by a given array of values.                                                                                   |
| [`identical`](xarray.CFTimeIndex.identical.html.md#xarray.CFTimeIndex.identical)(other)                                            | Similar to equals, but checks that object attributes and types are also equal.                                                       |
| `infer_objects`([copy])                                                                                                                   | If we have an object dtype, try to infer a non-object dtype.                                                                         |
| [`insert`](xarray.CFTimeIndex.insert.html.md#xarray.CFTimeIndex.insert)(loc, item)                                              | Make new Index inserting new item at location.                                                                                       |
| [`intersection`](xarray.CFTimeIndex.intersection.html.md#xarray.CFTimeIndex.intersection)(other[, sort])                              | Form the intersection of two Index objects.                                                                                          |
| [`is_`](xarray.CFTimeIndex.is_.html.md#xarray.CFTimeIndex.is_)(other)                                                        | More flexible, faster check like `is` but that works through views.                                                                  |
| [`isin`](xarray.CFTimeIndex.isin.html.md#xarray.CFTimeIndex.isin)(values[, level])                                            | Return a boolean array where the index values are in values.                                                                         |
| [`isna`](xarray.CFTimeIndex.isna.html.md#xarray.CFTimeIndex.isna)()                                                           | Detect missing values.                                                                                                               |
| [`isnull`](xarray.CFTimeIndex.isnull.html.md#xarray.CFTimeIndex.isnull)()                                                       | Detect missing values.                                                                                                               |
| [`item`](xarray.CFTimeIndex.item.html.md#xarray.CFTimeIndex.item)()                                                           | Return the first element of the underlying data as a Python scalar.                                                                  |
| [`join`](xarray.CFTimeIndex.join.html.md#xarray.CFTimeIndex.join)(other, \*[, how, level, ...])                               | Compute join_index and indexers to conform data structures to the new index.                                                         |
| [`map`](xarray.CFTimeIndex.map.html.md#xarray.CFTimeIndex.map)(mapper[, na_action])                                          | Map values using an input mapping or function.                                                                                       |
| [`max`](xarray.CFTimeIndex.max.html.md#xarray.CFTimeIndex.max)([axis, skipna])                                               | Return the maximum value of the Index.                                                                                               |
| [`memory_usage`](xarray.CFTimeIndex.memory_usage.html.md#xarray.CFTimeIndex.memory_usage)([deep])                                     | Memory usage of the values.                                                                                                          |
| [`min`](xarray.CFTimeIndex.min.html.md#xarray.CFTimeIndex.min)([axis, skipna])                                               | Return the minimum value of the Index.                                                                                               |
| [`notna`](xarray.CFTimeIndex.notna.html.md#xarray.CFTimeIndex.notna)()                                                         | Detect existing (non-missing) values.                                                                                                |
| [`notnull`](xarray.CFTimeIndex.notnull.html.md#xarray.CFTimeIndex.notnull)()                                                     | Detect existing (non-missing) values.                                                                                                |
| [`nunique`](xarray.CFTimeIndex.nunique.html.md#xarray.CFTimeIndex.nunique)([dropna])                                             | Return number of unique elements in the object.                                                                                      |
| [`putmask`](xarray.CFTimeIndex.putmask.html.md#xarray.CFTimeIndex.putmask)(mask, value)                                          | Return a new Index of the values set with the mask.                                                                                  |
| [`ravel`](xarray.CFTimeIndex.ravel.html.md#xarray.CFTimeIndex.ravel)([order])                                                  | Return a view on self.                                                                                                               |
| [`reindex`](xarray.CFTimeIndex.reindex.html.md#xarray.CFTimeIndex.reindex)(target[, method, level, limit, ...])                  | Create index with target's values.                                                                                                   |
| [`rename`](xarray.CFTimeIndex.rename.html.md#xarray.CFTimeIndex.rename)(name, \*[, inplace])                                    | Alter Index or MultiIndex name.                                                                                                      |
| [`repeat`](xarray.CFTimeIndex.repeat.html.md#xarray.CFTimeIndex.repeat)(repeats[, axis])                                        | Repeat elements of an Index.                                                                                                         |
| [`round`](xarray.CFTimeIndex.round.html.md#xarray.CFTimeIndex.round)(freq)                                                     | Round dates to a fixed frequency.                                                                                                    |
| [`searchsorted`](xarray.CFTimeIndex.searchsorted.html.md#xarray.CFTimeIndex.searchsorted)(value[, side, sorter])                      | Find indices where elements should be inserted to maintain order.                                                                    |
| [`set_names`](xarray.CFTimeIndex.set_names.html.md#xarray.CFTimeIndex.set_names)(names, \*[, level, inplace])                      | Set Index or MultiIndex name.                                                                                                        |
| [`shift`](xarray.CFTimeIndex.shift.html.md#xarray.CFTimeIndex.shift)(periods[, freq])                                          | Shift the CFTimeIndex a multiple of the given frequency.                                                                             |
| [`slice_indexer`](xarray.CFTimeIndex.slice_indexer.html.md#xarray.CFTimeIndex.slice_indexer)([start, end, step])                       | Compute the slice indexer for input labels and step.                                                                                 |
| [`slice_locs`](xarray.CFTimeIndex.slice_locs.html.md#xarray.CFTimeIndex.slice_locs)([start, end, step])                             | Compute slice locations for input labels.                                                                                            |
| [`sort_values`](xarray.CFTimeIndex.sort_values.html.md#xarray.CFTimeIndex.sort_values)(\*[, return_indexer, ascending, ...])         | Return a sorted copy of the index.                                                                                                   |
| [`sortlevel`](xarray.CFTimeIndex.sortlevel.html.md#xarray.CFTimeIndex.sortlevel)([level, ascending, ...])                          | For internal compatibility with the Index API.                                                                                       |
| [`strftime`](xarray.CFTimeIndex.strftime.html.md#xarray.CFTimeIndex.strftime)(date_format)                                        | Return an Index of formatted strings specified by date_format, which supports the same string format as the python standard library. |
| [`symmetric_difference`](xarray.CFTimeIndex.symmetric_difference.html.md#xarray.CFTimeIndex.symmetric_difference)(other[, result_name, sort]) | Compute the symmetric difference of two Index objects.                                                                               |
| [`take`](xarray.CFTimeIndex.take.html.md#xarray.CFTimeIndex.take)(indices[, axis, allow_fill, fill_value])                    | Return a new Index of the values selected by the indices.                                                                            |
| [`to_datetimeindex`](xarray.CFTimeIndex.to_datetimeindex.html.md#xarray.CFTimeIndex.to_datetimeindex)([unsafe, time_unit])                | If possible, convert this index to a pandas.DatetimeIndex.                                                                           |
| [`to_flat_index`](xarray.CFTimeIndex.to_flat_index.html.md#xarray.CFTimeIndex.to_flat_index)()                                         | Identity method.                                                                                                                     |
| [`to_frame`](xarray.CFTimeIndex.to_frame.html.md#xarray.CFTimeIndex.to_frame)([index, name])                                      | Create a DataFrame with a column containing the Index.                                                                               |
| [`to_list`](xarray.CFTimeIndex.to_list.html.md#xarray.CFTimeIndex.to_list)()                                                     | Return a list of the values.                                                                                                         |
| [`to_numpy`](xarray.CFTimeIndex.to_numpy.html.md#xarray.CFTimeIndex.to_numpy)([dtype, copy, na_value])                            | A NumPy ndarray representing the values in this Series or Index.                                                                     |
| [`to_series`](xarray.CFTimeIndex.to_series.html.md#xarray.CFTimeIndex.to_series)([index, name])                                    | Create a Series with both index and values equal to the index keys.                                                                  |
| [`tolist`](xarray.CFTimeIndex.tolist.html.md#xarray.CFTimeIndex.tolist)()                                                       | Return a list of the values.                                                                                                         |
| [`transpose`](xarray.CFTimeIndex.transpose.html.md#xarray.CFTimeIndex.transpose)(\*args, \*\*kwargs)                               | Return the transpose, which is by definition self.                                                                                   |
| [`union`](xarray.CFTimeIndex.union.html.md#xarray.CFTimeIndex.union)(other[, sort])                                            | Form the union of two Index objects.                                                                                                 |
| [`unique`](xarray.CFTimeIndex.unique.html.md#xarray.CFTimeIndex.unique)([level])                                                | Return unique values in the index.                                                                                                   |
| [`value_counts`](xarray.CFTimeIndex.value_counts.html.md#xarray.CFTimeIndex.value_counts)([normalize, sort, ascending, ...])          | Return a Series containing counts of unique values.                                                                                  |
| [`view`](xarray.CFTimeIndex.view.html.md#xarray.CFTimeIndex.view)([cls])                                                      | Return a view of the Index with the specified dtype or a new Index instance.                                                         |
| [`where`](xarray.CFTimeIndex.where.html.md#xarray.CFTimeIndex.where)(cond[, other])                                            | Replace values where the condition is False.                                                                                         |

### Attributes

| [`T`](xarray.CFTimeIndex.T.html.md#xarray.CFTimeIndex.T)                                             | Return the transpose, which is by definition self.               |
|---------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| [`array`](xarray.CFTimeIndex.array.html.md#xarray.CFTimeIndex.array)                                     | The ExtensionArray of the data backing this Index.               |
| [`asi8`](xarray.CFTimeIndex.asi8.html.md#xarray.CFTimeIndex.asi8)                                       | Convert to integers with units of microseconds since 1970-01-01. |
| [`calendar`](xarray.CFTimeIndex.calendar.html.md#xarray.CFTimeIndex.calendar)                               | The calendar used by the datetimes in the index.                 |
| [`date_type`](xarray.CFTimeIndex.date_type.html.md#xarray.CFTimeIndex.date_type)                             |                                                                  |
| [`day`](xarray.CFTimeIndex.day.html.md#xarray.CFTimeIndex.day)                                         | The days of the datetime                                         |
| [`day_of_week`](xarray.CFTimeIndex.day_of_week.html.md#xarray.CFTimeIndex.day_of_week)                         | The day of week of the datetime                                  |
| [`day_of_year`](xarray.CFTimeIndex.day_of_year.html.md#xarray.CFTimeIndex.day_of_year)                         | The ordinal day of year of the datetime                          |
| [`dayofweek`](xarray.CFTimeIndex.dayofweek.html.md#xarray.CFTimeIndex.dayofweek)                             | The day of week of the datetime                                  |
| [`dayofyear`](xarray.CFTimeIndex.dayofyear.html.md#xarray.CFTimeIndex.dayofyear)                             | The ordinal day of year of the datetime                          |
| [`days_in_month`](xarray.CFTimeIndex.days_in_month.html.md#xarray.CFTimeIndex.days_in_month)                     | The number of days in the month of the datetime                  |
| [`dtype`](xarray.CFTimeIndex.dtype.html.md#xarray.CFTimeIndex.dtype)                                     | Return the dtype object of the underlying data.                  |
| [`empty`](xarray.CFTimeIndex.empty.html.md#xarray.CFTimeIndex.empty)                                     | Indicator whether Index is empty.                                |
| [`freq`](xarray.CFTimeIndex.freq.html.md#xarray.CFTimeIndex.freq)                                       | The frequency used by the dates in the index.                    |
| [`has_duplicates`](xarray.CFTimeIndex.has_duplicates.html.md#xarray.CFTimeIndex.has_duplicates)                   | Check if the Index has duplicate values.                         |
| [`hasnans`](xarray.CFTimeIndex.hasnans.html.md#xarray.CFTimeIndex.hasnans)                                 | Return True if there are any NaNs.                               |
| [`hour`](xarray.CFTimeIndex.hour.html.md#xarray.CFTimeIndex.hour)                                       | The hours of the datetime                                        |
| [`inferred_type`](xarray.CFTimeIndex.inferred_type.html.md#xarray.CFTimeIndex.inferred_type)                     | Return a string of the type inferred from the values.            |
| `is_leap_year`                                                                                                      |                                                                  |
| [`is_monotonic_decreasing`](xarray.CFTimeIndex.is_monotonic_decreasing.html.md#xarray.CFTimeIndex.is_monotonic_decreasing) | Return a boolean if the values are equal or decreasing.          |
| [`is_monotonic_increasing`](xarray.CFTimeIndex.is_monotonic_increasing.html.md#xarray.CFTimeIndex.is_monotonic_increasing) | Return a boolean if the values are equal or increasing.          |
| [`is_unique`](xarray.CFTimeIndex.is_unique.html.md#xarray.CFTimeIndex.is_unique)                             | Return if the index has unique values.                           |
| [`microsecond`](xarray.CFTimeIndex.microsecond.html.md#xarray.CFTimeIndex.microsecond)                         | The microseconds of the datetime                                 |
| [`minute`](xarray.CFTimeIndex.minute.html.md#xarray.CFTimeIndex.minute)                                   | The minutes of the datetime                                      |
| [`month`](xarray.CFTimeIndex.month.html.md#xarray.CFTimeIndex.month)                                     | The month of the datetime                                        |
| [`name`](xarray.CFTimeIndex.name.html.md#xarray.CFTimeIndex.name)                                       | Return Index or MultiIndex name.                                 |
| [`names`](xarray.CFTimeIndex.names.html.md#xarray.CFTimeIndex.names)                                     | Get names on index.                                              |
| [`nbytes`](xarray.CFTimeIndex.nbytes.html.md#xarray.CFTimeIndex.nbytes)                                   | Return the number of bytes in the underlying data.               |
| [`ndim`](xarray.CFTimeIndex.ndim.html.md#xarray.CFTimeIndex.ndim)                                       | Number of dimensions of the underlying data, by definition 1.    |
| [`nlevels`](xarray.CFTimeIndex.nlevels.html.md#xarray.CFTimeIndex.nlevels)                                 | Number of levels.                                                |
| [`second`](xarray.CFTimeIndex.second.html.md#xarray.CFTimeIndex.second)                                   | The seconds of the datetime                                      |
| [`shape`](xarray.CFTimeIndex.shape.html.md#xarray.CFTimeIndex.shape)                                     | Return a tuple of the shape of the underlying data.              |
| [`size`](xarray.CFTimeIndex.size.html.md#xarray.CFTimeIndex.size)                                       | Return the number of elements in the underlying data.            |
| [`values`](xarray.CFTimeIndex.values.html.md#xarray.CFTimeIndex.values)                                   | Return an array representing the data in the Index.              |
| [`year`](xarray.CFTimeIndex.year.html.md#xarray.CFTimeIndex.year)                                       | The year of the datetime                                         |
