Skip to main content
`Ctrl`+`K`

# Index objects

## Index

Many of these methods or variants thereof are available on the objects that contain an index (Series/DataFrame) and those should most likely be used before calling these methods directly.

`Index`([data, dtype, copy, name, tupleize_cols]) | Immutable sequence used for indexing and alignment.

### Properties

`Index.values` | Return an array representing the data in the Index.
`Index.is_monotonic_increasing` | Return a boolean if the values are equal or increasing.
`Index.is_monotonic_decreasing` | Return a boolean if the values are equal or decreasing.
`Index.is_unique` | Return if the index has unique values.
`Index.has_duplicates` | Check if the Index has duplicate values.
`Index.hasnans` | Return True if there are any NaNs.
`Index.dtype` | Return the dtype object of the underlying data.
`Index.inferred_type` | Return a string of the type inferred from the values.
`Index.shape` | Return a tuple of the shape of the underlying data.
`Index.name` | Return Index or MultiIndex name.
`Index.names` | Get names on index.
`Index.nbytes` | Return the number of bytes in the underlying data.
`Index.ndim` | Number of dimensions of the underlying data, by definition 1.
`Index.size` | Return the number of elements in the underlying data.
`Index.empty` | Indicator whether Index is empty.
`Index.T` | Return the transpose, which is by definition self.
`Index.memory_usage`([deep]) | Memory usage of the values.
`Index.array` | The ExtensionArray of the data backing this Series or Index.

### Modifying and computations

`Index.all`(*args, **kwargs) | Return whether all elements are Truthy.
`Index.any`(*args, **kwargs) | Return whether any element is Truthy.
`Index.argmin`([axis, skipna]) | Return int position of the smallest value in the Series.
`Index.argmax`([axis, skipna]) | Return int position of the largest value in the Series.
`Index.copy`([name, deep]) | Make a copy of this object.
`Index.delete`(loc) | Make new Index with passed location(-s) deleted.
`Index.drop`(labels[, errors]) | Make new Index with passed list of labels deleted.
`Index.drop_duplicates`(*[, keep]) | Return Index with duplicate values removed.
`Index.duplicated`([keep]) | Indicate duplicate index values.
`Index.equals`(other) | Determine if two Index object are equal.
`Index.factorize`([sort, use_na_sentinel]) | Encode the object as an enumerated type or categorical variable.
`Index.identical`(other) | Similar to equals, but checks that object attributes and types are also equal.
`Index.insert`(loc, item) | Make new Index inserting new item at location.
`Index.is_`(other) | More flexible, faster check like `is` but that works through views.
`Index.min`([axis, skipna]) | Return the minimum value of the Index.
`Index.max`([axis, skipna]) | Return the maximum value of the Index.
`Index.reindex`(target[, method, level, ...]) | Create index with target's values.
`Index.rename`(name, *[, inplace]) | Alter Index or MultiIndex name.
`Index.repeat`(repeats[, axis]) | Repeat elements of an Index.
`Index.where`(cond[, other]) | Replace values where the condition is False.
`Index.take`(indices[, axis, allow_fill, ...]) | Return a new Index of the values selected by the indices.
`Index.putmask`(mask, value) | Return a new Index of the values set with the mask.
`Index.unique`([level]) | Return unique values in the index.
`Index.nunique`([dropna]) | Return number of unique elements in the object.
`Index.value_counts`([normalize, sort, ...]) | Return a Series containing counts of unique values.

### Compatibility with MultiIndex

`Index.set_names`(names, *[, level, inplace]) | Set Index or MultiIndex name.
`Index.droplevel`([level]) | Return index with requested level(s) removed.

### Missing values

`Index.fillna`(value) | Fill NA/NaN values with the specified value.
`Index.dropna`([how]) | Return Index without NA/NaN values.
`Index.isna`() | Detect missing values.
`Index.notna`() | Detect existing (non-missing) values.

### Conversion

`Index.astype`(dtype[, copy]) | Create an Index with values cast to dtypes.
`Index.infer_objects`([copy]) | If we have an object dtype, try to infer a non-object dtype.
`Index.item`() | Return the first element of the underlying data as a Python scalar.
`Index.map`(mapper[, na_action]) | Map values using an input mapping or function.
`Index.ravel`([order]) | Return a view on self.
`Index.to_list`() | Return a list of the values.
`Index.to_series`([index, name]) | Create a Series with both index and values equal to the index keys.
`Index.to_frame`([index, name]) | Create a DataFrame with a column containing the Index.
`Index.to_numpy`([dtype, copy, na_value]) | A NumPy ndarray representing the values in this Series or Index.
`Index.view`([cls]) | Return a view of the Index with the specified dtype or a new Index instance.

### Sorting

`Index.argsort`(*args, **kwargs) | Return the integer indices that would sort the index.
`Index.searchsorted`(value[, side, sorter]) | Find indices where elements should be inserted to maintain order.
`Index.sort_values`(*[, return_indexer, ...]) | Return a sorted copy of the index.

### Time-specific operations

`Index.shift`([periods, freq]) | Shift index by desired number of time frequency increments.

### Combining / joining / set operations

`Index.append`(other) | Append a collection of Index options together.
`Index.join`(other, *[, how, level, ...]) | Compute join_index and indexers to conform data structures to the new index.
`Index.intersection`(other[, sort]) | Form the intersection of two Index objects.
`Index.union`(other[, sort]) | Form the union of two Index objects.
`Index.difference`(other[, sort]) | Return a new Index with elements of index not in other.
`Index.symmetric_difference`(other[, ...]) | Compute the symmetric difference of two Index objects.

### Selecting

`Index.asof`(label) | Return the label from the index, or, if not present, the previous one.
`Index.asof_locs`(where, mask) | Return the locations (indices) of labels in the index.
`Index.get_indexer`(target[, method, limit, ...]) | Compute indexer and mask for new index given the current index.
`Index.get_indexer_for`(target) | Guaranteed return of an indexer even when non-unique.
`Index.get_indexer_non_unique`(target) | Compute indexer and mask for new index given the current index.
`Index.get_level_values`(level) | Return an Index of values for requested level.
`Index.get_loc`(key) | Get integer location, slice or boolean mask for requested label.
`Index.get_slice_bound`(label, side) | Calculate slice bound that corresponds to given label.
`Index.isin`(values[, level]) | Return a boolean array where the index values are in values.
`Index.slice_indexer`([start, end, step]) | Compute the slice indexer for input labels and step.
`Index.slice_locs`([start, end, step]) | Compute slice locations for input labels.

## Numeric Index

`RangeIndex`([start, stop, step, dtype, copy, ...]) | Immutable Index implementing a monotonic integer range.

`RangeIndex.start` | The value of the start parameter (`0` if this was not supplied).
`RangeIndex.stop` | The value of the stop parameter.
`RangeIndex.step` | The value of the step parameter (`1` if this was not supplied).
`RangeIndex.from_range`(data[, name, dtype]) | Create `pandas.RangeIndex` from a `range` object.

## CategoricalIndex

`CategoricalIndex`([data, categories, ...]) | Index based on an underlying `Categorical`.

### Categorical components

`CategoricalIndex.append`(other) | Append a collection of Index options together.
`CategoricalIndex.codes` | The category codes of this categorical index.
`CategoricalIndex.categories` | The categories of this categorical.
`CategoricalIndex.ordered` | Whether the categories have an ordered relationship.
`CategoricalIndex.rename_categories`(...) | Rename categories.
`CategoricalIndex.reorder_categories`(...[, ...]) | Reorder categories as specified in new_categories.
`CategoricalIndex.add_categories`(new_categories) | Add new categories.
`CategoricalIndex.remove_categories`(removals) | Remove the specified categories.
`CategoricalIndex.remove_unused_categories`() | Remove categories which are not used.
`CategoricalIndex.set_categories`(new_categories) | Set the categories to the specified new categories.
`CategoricalIndex.as_ordered`() | Set the Categorical to be ordered.
`CategoricalIndex.as_unordered`() | Set the Categorical to be unordered.

### Modifying and computations

`CategoricalIndex.map`(mapper[, na_action]) | Map values using input an input mapping or function.
`CategoricalIndex.equals`(other) | Determine if two CategoricalIndex objects contain the same elements.

## IntervalIndex

`IntervalIndex`(data[, closed, dtype, copy, ...]) | Immutable index of intervals that are closed on the same side.

### IntervalIndex components

`IntervalIndex.from_arrays`(left, right[, ...]) | Construct from two arrays defining the left and right bounds.
`IntervalIndex.from_tuples`(data[, closed, ...]) | Construct an IntervalIndex from an array-like of tuples.
`IntervalIndex.from_breaks`(breaks[, closed, ...]) | Construct an IntervalIndex from an array of splits.
`IntervalIndex.left` | Return left bounds of the intervals in the IntervalIndex.
`IntervalIndex.right` | Return right bounds of the intervals in the IntervalIndex.
`IntervalIndex.mid` | Return the midpoint of each interval in the IntervalIndex as an Index.
`IntervalIndex.closed` | String describing the inclusive side the intervals.
`IntervalIndex.length` | Calculate the length of each interval in the IntervalIndex.
`IntervalIndex.values` | Return an array representing the data in the Index.
`IntervalIndex.is_empty` | Indicates if an interval is empty, meaning it contains no points.
`IntervalIndex.is_non_overlapping_monotonic` | Return a boolean whether the IntervalArray/IntervalIndex is non-overlapping and monotonic.
`IntervalIndex.is_overlapping` | Return True if the IntervalIndex has overlapping intervals, else False.
`IntervalIndex.get_loc`(key) | Get integer location, slice or boolean mask for requested label.
`IntervalIndex.get_indexer`(target[, method, ...]) | Compute indexer and mask for new index given the current index.
`IntervalIndex.set_closed`(closed) | Return an identical IntervalArray closed on the specified side.
`IntervalIndex.contains`(other) | Check elementwise if the Intervals contain the value.
`IntervalIndex.overlaps`(other) | Check elementwise if an Interval overlaps the values in the IntervalArray.
`IntervalIndex.to_tuples`([na_tuple]) | Return an ndarray (if self is IntervalArray) or Index (if self is IntervalIndex) of tuples of the form (left, right).

## MultiIndex

`MultiIndex`([levels, codes, sortorder, ...]) | A multi-level, or hierarchical, index object for pandas objects.

### MultiIndex constructors

`MultiIndex.from_arrays`(arrays[, sortorder, ...]) | Convert arrays to MultiIndex.
`MultiIndex.from_tuples`(tuples[, sortorder, ...]) | Convert list of tuples to MultiIndex.
`MultiIndex.from_product`(iterables[, ...]) | Make a MultiIndex from the cartesian product of multiple iterables.
`MultiIndex.from_frame`(df[, sortorder, names]) | Make a MultiIndex from a DataFrame.

### MultiIndex properties

`MultiIndex.names` | Names of levels in MultiIndex.
`MultiIndex.levels` | Levels of the MultiIndex.
`MultiIndex.codes` | Codes of the MultiIndex.
`MultiIndex.nlevels` | Integer number of levels in this MultiIndex.
`MultiIndex.levshape` | A tuple representing the length of each level in the MultiIndex.
`MultiIndex.dtypes` | Return the dtypes as a Series for the underlying MultiIndex.

### MultiIndex components

`MultiIndex.set_levels`(levels, *[, level, ...]) | Set new levels on MultiIndex.
`MultiIndex.set_codes`(codes, *[, level, ...]) | Set new codes on MultiIndex.
`MultiIndex.to_flat_index`() | Convert a MultiIndex to an Index of Tuples containing the level values.
`MultiIndex.to_frame`([index, name, ...]) | Create a DataFrame with the levels of the MultiIndex as columns.
`MultiIndex.sortlevel`([level, ascending, ...]) | Sort MultiIndex at the requested level.
`MultiIndex.droplevel`([level]) | Return index with requested level(s) removed.
`MultiIndex.swaplevel`([i, j]) | Swap level i with level j.
`MultiIndex.reorder_levels`(order) | Rearrange levels using input order.
`MultiIndex.remove_unused_levels`() | Create new MultiIndex from current that removes unused levels.
`MultiIndex.drop`(codes[, level, errors]) | Make a new `pandas.MultiIndex` with the passed list of codes deleted.
`MultiIndex.copy`([names, deep, name]) | Make a copy of this object.
`MultiIndex.append`(other) | Append a collection of Index options together.
`MultiIndex.truncate`([before, after]) | Slice index between two labels / tuples, return new MultiIndex.

### MultiIndex selecting

`MultiIndex.get_loc`(key) | Get location for a label or a tuple of labels.
`MultiIndex.get_locs`(seq) | Get location for a sequence of labels.
`MultiIndex.get_loc_level`(key[, level, ...]) | Get location and sliced index for requested label(s)/level(s).
`MultiIndex.get_indexer`(target[, method, ...]) | Compute indexer and mask for new index given the current index.
`MultiIndex.get_level_values`(level) | Return vector of label values for requested level.

`IndexSlice` | Create an object to more easily perform multi-index slicing.

## DatetimeIndex

`DatetimeIndex`([data, freq, tz, ambiguous, ...]) | Immutable ndarray-like of datetime64 data.

### Time/date components

`DatetimeIndex.year` | The year of the datetime.
`DatetimeIndex.month` | The month as January=1, December=12.
`DatetimeIndex.day` | The day of the datetime.
`DatetimeIndex.hour` | The hours of the datetime.
`DatetimeIndex.minute` | The minutes of the datetime.
`DatetimeIndex.second` | The seconds of the datetime.
`DatetimeIndex.microsecond` | The microseconds of the datetime.
`DatetimeIndex.nanosecond` | The nanoseconds of the datetime.
`DatetimeIndex.date` | Returns numpy array of python `datetime.date` objects.
`DatetimeIndex.time` | Returns numpy array of `datetime.time` objects.
`DatetimeIndex.timetz` | Returns numpy array of `datetime.time` objects with timezones.
`DatetimeIndex.dayofyear` | The ordinal day of the year.
`DatetimeIndex.day_of_year` | The ordinal day of the year.
`DatetimeIndex.dayofweek` | The day of the week with Monday=0, Sunday=6.
`DatetimeIndex.day_of_week` | The day of the week with Monday=0, Sunday=6.
`DatetimeIndex.weekday` | The day of the week with Monday=0, Sunday=6.
`DatetimeIndex.quarter` | The quarter of the date.
`DatetimeIndex.tz` | Return the timezone.
`DatetimeIndex.freq` | Return the frequency object if it is set, otherwise None.
`DatetimeIndex.freqstr` | Return the frequency object as a string if it's set, otherwise None.
`DatetimeIndex.is_month_start` | Indicates whether the date is the first day of the month.
`DatetimeIndex.is_month_end` | Indicates whether the date is the last day of the month.
`DatetimeIndex.is_quarter_start` | Indicator for whether the date is the first day of a quarter.
`DatetimeIndex.is_quarter_end` | Indicator for whether the date is the last day of a quarter.
`DatetimeIndex.is_year_start` | Indicate whether the date is the first day of a year.
`DatetimeIndex.is_year_end` | Indicate whether the date is the last day of the year.
`DatetimeIndex.is_leap_year` | Boolean indicator if the date belongs to a leap year.
`DatetimeIndex.inferred_freq` | Return the inferred frequency of the index.

### Selecting

`DatetimeIndex.indexer_at_time`(time[, asof]) | Return index locations of values at particular time of day.
`DatetimeIndex.indexer_between_time`(...[, ...]) | Return index locations of values between particular times of day.

### Time-specific operations

`DatetimeIndex.normalize`() | Convert times to midnight.
`DatetimeIndex.strftime`(date_format) | Convert to Index using specified date_format.
`DatetimeIndex.snap`([freq]) | Snap time stamps to nearest occurring frequency.
`DatetimeIndex.tz_convert`(tz) | Convert tz-aware Datetime Array/Index from one time zone to another.
`DatetimeIndex.tz_localize`(tz[, ambiguous, ...]) | Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index.
`DatetimeIndex.round`(freq[, ambiguous, ...]) | Perform round operation on the data to the specified freq.
`DatetimeIndex.floor`(freq[, ambiguous, ...]) | Perform floor operation on the data to the specified freq.
`DatetimeIndex.ceil`(freq[, ambiguous, ...]) | Perform ceil operation on the data to the specified freq.
`DatetimeIndex.month_name`([locale]) | Return the month names with specified locale.
`DatetimeIndex.day_name`([locale]) | Return the day names with specified locale.

### Conversion

`DatetimeIndex.as_unit`(unit[, round_ok]) | Convert to a dtype with the given unit resolution.
`DatetimeIndex.to_period`([freq]) | Cast to PeriodArray/PeriodIndex at a particular frequency.
`DatetimeIndex.to_pydatetime`() | Return an ndarray of `datetime.datetime` objects.
`DatetimeIndex.to_series`([index, name]) | Create a Series with both index and values equal to the index keys.
`DatetimeIndex.to_frame`([index, name]) | Create a DataFrame with a column containing the Index.
`DatetimeIndex.to_julian_date`() | Convert TimeStamp to a Julian Date.

### Methods

`DatetimeIndex.mean`(*[, skipna, axis]) | Return the mean value of the Array.
`DatetimeIndex.std`([axis, dtype, out, ddof, ...]) | Return sample standard deviation over requested axis.

## TimedeltaIndex

`TimedeltaIndex`([data, freq, dtype, copy, name]) | Immutable Index of timedelta64 data.

### Components

`TimedeltaIndex.days` | Number of days for each element.
`TimedeltaIndex.seconds` | Number of seconds (>= 0 and less than 1 day) for each element.
`TimedeltaIndex.microseconds` | Number of microseconds (>= 0 and less than 1 second) for each element.
`TimedeltaIndex.nanoseconds` | Number of nanoseconds (>= 0 and less than 1 microsecond) for each element.
`TimedeltaIndex.components` | Return a DataFrame of the individual resolution components of the Timedeltas.
`TimedeltaIndex.inferred_freq` | Return the inferred frequency of the index.

### Conversion

`TimedeltaIndex.as_unit`(unit) | Convert to a dtype with the given unit resolution.
`TimedeltaIndex.to_pytimedelta`() | Return an ndarray of datetime.timedelta objects.
`TimedeltaIndex.to_series`([index, name]) | Create a Series with both index and values equal to the index keys.
`TimedeltaIndex.round`(freq[, ambiguous, ...]) | Perform round operation on the data to the specified freq.
`TimedeltaIndex.floor`(freq[, ambiguous, ...]) | Perform floor operation on the data to the specified freq.
`TimedeltaIndex.ceil`(freq[, ambiguous, ...]) | Perform ceil operation on the data to the specified freq.
`TimedeltaIndex.to_frame`([index, name]) | Create a DataFrame with a column containing the Index.

### Methods

`TimedeltaIndex.mean`(*[, skipna, axis]) | Return the mean value of the Array.

## PeriodIndex

`PeriodIndex`([data, freq, dtype, copy, name]) | Immutable ndarray holding ordinal values indicating regular periods in time.

### Properties

`PeriodIndex.day` | The days of the period.
`PeriodIndex.dayofweek` | The day of the week with Monday=0, Sunday=6.
`PeriodIndex.day_of_week` | The day of the week with Monday=0, Sunday=6.
`PeriodIndex.dayofyear` | The ordinal day of the year.
`PeriodIndex.day_of_year` | The ordinal day of the year.
`PeriodIndex.days_in_month` | The number of days in the month.
`PeriodIndex.daysinmonth` | The number of days in the month.
`PeriodIndex.end_time` | Get the Timestamp for the end of the period.
`PeriodIndex.freq` | Return the frequency object if it is set, otherwise None.
`PeriodIndex.freqstr` | Return the frequency object as a string if it's set, otherwise None.
`PeriodIndex.hour` | The hour of the period.
`PeriodIndex.is_leap_year` | Logical indicating if the date belongs to a leap year.
`PeriodIndex.minute` | The minute of the period.
`PeriodIndex.month` | The month as January=1, December=12.
`PeriodIndex.quarter` | The quarter of the date.
`PeriodIndex.qyear` | Fiscal year the Period lies in according to its starting-quarter.
`PeriodIndex.second` | The second of the period.
`PeriodIndex.start_time` | Get the Timestamp for the start of the period.
`PeriodIndex.week` | The week ordinal of the year.
`PeriodIndex.weekday` | The day of the week with Monday=0, Sunday=6.
`PeriodIndex.weekofyear` | The week ordinal of the year.
`PeriodIndex.year` | The year of the period.

### Methods

`PeriodIndex.asfreq`([freq, how]) | Convert the PeriodArray to the specified frequency freq.
`PeriodIndex.strftime`(date_format) | Convert to Index using specified date_format.
`PeriodIndex.to_timestamp`([freq, how]) | Cast to DatetimeArray/Index.
`PeriodIndex.from_fields`(*[, year, quarter, ...]) | Construct a PeriodIndex from fields (year, month, day, etc.).
`PeriodIndex.from_ordinals`(ordinals, *, freq) | Construct a PeriodIndex from ordinals.