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.
| Immutable sequence used for indexing and alignment. |
Properties
Return an array representing the data in the Index. | |
Alias for is_monotonic_increasing. | |
Return if the index is monotonic increasing (only equal or increasing) values. | |
Return if the index is monotonic decreasing (only equal or decreasing) values. | |
Return if the index has unique values. | |
Check if the Index has duplicate values. | |
Return if I have any nans; enables various perf speedups. | |
Return the dtype object of the underlying data. | |
Return a string of the type inferred from the values. | |
Whether or not the index values only consist of dates. | |
Return a tuple of the shape of the underlying data. | |
Return Index or MultiIndex name. | |
Return the number of bytes in the underlying data. | |
Number of dimensions of the underlying data, by definition 1. | |
Return the number of elements in the underlying data. | |
Return the transpose, which is by definition self. | |
| Memory usage of the values. |
Modifying and computations
| Return whether all elements are Truthy. |
| Return whether any element is Truthy. |
| Return int position of the smallest value in the Series. |
| Return int position of the largest value in the Series. |
| Make a copy of this object. |
| Make new Index with passed location(-s) deleted. |
| Make new Index with passed list of labels deleted. |
| Return Index with duplicate values removed. |
| Indicate duplicate index values. |
| Determine if two Index object are equal. |
| Encode the object as an enumerated type or categorical variable. |
| Similar to equals, but checks that object attributes and types are also equal. |
| Make new Index inserting new item at location. |
| More flexible, faster check like |
Check if the Index only consists of booleans. | |
Check if the Index holds categorical data. | |
Check if the Index is a floating type. | |
Check if the Index only consists of integers. | |
Check if the Index holds Interval objects. | |
Check if the Index holds data with mixed data types. | |
Check if the Index only consists of numeric data. | |
Check if the Index is of the object dtype. | |
| Return the minimum value of the Index. |
| Return the maximum value of the Index. |
| Create index with target's values. |
| Alter Index or MultiIndex name. |
| Repeat elements of a Index. |
| Replace values where the condition is False. |
| Return a new Index of the values selected by the indices. |
| Return a new Index of the values set with the mask. |
| Return unique values in the index. |
| Return number of unique elements in the object. |
| Return a Series containing counts of unique values. |
Compatibility with MultiIndex
| Set Index or MultiIndex name. |
| Return index with requested level(s) removed. |
Missing values
| Fill NA/NaN values with the specified value. |
| Return Index without NA/NaN values. |
Detect missing values. | |
Detect existing (non-missing) values. |
Conversion
| Create an Index with values cast to dtypes. |
Return the first element of the underlying data as a Python scalar. | |
| Map values using input correspondence (a dict, Series, or function). |
| Return an ndarray of the flattened values of the underlying data. |
Return a list of the values. | |
| (DEPRECATED) Format specified values of self and return them. |
| Create a Series with both index and values equal to the index keys. |
| Create a DataFrame with a column containing the Index. |
|
Sorting
| Return the integer indices that would sort the index. |
| Find indices where elements should be inserted to maintain order. |
| Return a sorted copy of the index. |
Time-specific operations
| Shift index by desired number of time frequency increments. |
Combining / joining / set operations
| Append a collection of Index options together. |
| Compute join_index and indexers to conform data structures to the new index. |
| Form the intersection of two Index objects. |
| Form the union of two Index objects. |
| Return a new Index with elements of index not in other. |
| Compute the symmetric difference of two Index objects. |
Selecting
| Return the label from the index, or, if not present, the previous one. |
| Return the locations (indices) of labels in the index. |
| Compute indexer and mask for new index given the current index. |
| Guaranteed return of an indexer even when non-unique. |
| Compute indexer and mask for new index given the current index. |
| Return an Index of values for requested level. |
| Get integer location, slice or boolean mask for requested label. |
| Calculate slice bound that corresponds to given label. |
| Fast lookup of value from 1-dimensional ndarray. |
| Return a boolean array where the index values are in values. |
| Compute the slice indexer for input labels and step. |
| Compute slice locations for input labels. |
Numeric Index
| Immutable Index implementing a monotonic integer range. |
| Immutable sequence used for indexing and alignment. |
| Immutable sequence used for indexing and alignment. |
| Immutable sequence used for indexing and alignment. |
The value of the start parameter ( | |
The value of the stop parameter. | |
The value of the step parameter ( | |
| Create RangeIndex from a range object. |
CategoricalIndex
| Index based on an underlying |
Categorical components
The category codes of this categorical. | |
The categories of this categorical. | |
Whether the categories have an ordered relationship. | |
| Rename categories. |
| Reorder categories as specified in new_categories. |
| Add new categories. |
| Remove the specified categories. |
Remove categories which are not used. | |
| Set the categories to the specified new_categories. |
| Set the Categorical to be ordered. |
| Set the Categorical to be unordered. |
Modifying and computations
| Map values using input correspondence (a dict, Series, or function). |
| Determine if two CategoricalIndex objects contain the same elements. |
IntervalIndex
| Immutable index of intervals that are closed on the same side. |
IntervalIndex components
| Construct from two arrays defining the left and right bounds. |
| Construct an IntervalIndex from an array-like of tuples. |
| Construct an IntervalIndex from an array of splits. |
Whether the intervals are closed on the left-side, right-side, both or neither. | |
Return an array representing the data in the Index. | |
Indicates if an interval is empty, meaning it contains no points. | |
Return True if the IntervalArray is non-overlapping (no Intervals share points) and is either monotonic increasing or monotonic decreasing, else False. | |
Return True if the IntervalIndex has overlapping intervals, else False. | |
| Get integer location, slice or boolean mask for requested label. |
| Compute indexer and mask for new index given the current index. |
| Return an IntervalArray identical to the current one, but closed on the specified side. |
| Check elementwise if the Intervals contain the value. |
| Check elementwise if an Interval overlaps the values in the IntervalArray. |
| Return an ndarray of tuples of the form (left, right). |
MultiIndex
| A multi-level, or hierarchical, index object for pandas objects. |
Create an object to more easily perform multi-index slicing. |
MultiIndex constructors
| Convert arrays to MultiIndex. |
| Convert list of tuples to MultiIndex. |
| Make a MultiIndex from the cartesian product of multiple iterables. |
| Make a MultiIndex from a DataFrame. |
MultiIndex properties
Names of levels in MultiIndex. | |
Integer number of levels in this MultiIndex. | |
A tuple with the length of each level. | |
Return the dtypes as a Series for the underlying MultiIndex |
MultiIndex components
| Set new levels on MultiIndex. |
| Set new codes on MultiIndex. |
Convert a MultiIndex to an Index of Tuples containing the level values. | |
| Create a DataFrame with the levels of the MultiIndex as columns. |
| Sort MultiIndex at the requested level. |
| Return index with requested level(s) removed. |
| Swap level i with level j. |
| Rearrange levels using input order. |
Create new MultiIndex from current that removes unused levels. |
MultiIndex selecting
| Get location for a label or a tuple of labels. |
| Get location for a sequence of labels. |
| Get location and sliced index for requested label(s)/level(s). |
| Compute indexer and mask for new index given the current index. |
| Return vector of label values for requested level. |
DatetimeIndex
| Immutable ndarray-like of datetime64 data. |
Time/date components
The year of the datetime. | |
The month as January=1, December=12. | |
The day of the datetime. | |
The hours of the datetime. | |
The minutes of the datetime. | |
The seconds of the datetime. | |
The microseconds of the datetime. | |
The nanoseconds of the datetime. | |
Returns numpy array of python datetime.date objects (namely, the date part of Timestamps without timezone information). | |
Returns numpy array of datetime.time. | |
Returns numpy array of datetime.time also containing timezone information. | |
The ordinal day of the year. | |
The ordinal day of the year. | |
(DEPRECATED) The week ordinal of the year. | |
(DEPRECATED) The week ordinal of the year. | |
The day of the week with Monday=0, Sunday=6. | |
The day of the week with Monday=0, Sunday=6. | |
The day of the week with Monday=0, Sunday=6. | |
The quarter of the date. | |
Return timezone, if any. | |
Return the frequency object if it is set, otherwise None. | |
Return the frequency object as a string if its set, otherwise None. | |
Indicates whether the date is the first day of the month. | |
Indicates whether the date is the last day of the month. | |
Indicator for whether the date is the first day of a quarter. | |
Indicator for whether the date is the last day of a quarter. | |
Indicate whether the date is the first day of a year. | |
Indicate whether the date is the last day of the year. | |
Boolean indicator if the date belongs to a leap year. | |
Tries to return a string representing a frequency guess, generated by infer_freq. |
Selecting
| Return index locations of values at particular time of day (e.g. |
| Return index locations of values between particular times of day (e.g., 9:00-9:30AM). |
Time-specific operations
| Convert times to midnight. |
| Convert to Index using specified date_format. |
| Snap time stamps to nearest occurring frequency. |
Convert tz-aware Datetime Array/Index from one time zone to another. | |
| Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. |
| Perform round operation on the data to the specified freq. |
| Perform floor operation on the data to the specified freq. |
| Perform ceil operation on the data to the specified freq. |
| Return the month names of the DateTimeIndex with specified locale. |
| Return the day names of the DateTimeIndex with specified locale. |
Conversion
| Cast to PeriodArray/Index at a particular frequency. |
Calculate TimedeltaArray of difference between index values and index converted to PeriodArray at specified freq. | |
| Return Datetime Array/Index as object ndarray of datetime.datetime objects. |
| Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index. |
| Create a DataFrame with a column containing the Index. |
Methods
| Return the mean value of the Array. |
TimedeltaIndex
| Immutable ndarray of timedelta64 data, represented internally as int64, and which can be boxed to timedelta objects. |
Components
Number of days for each element. | |
Number of seconds (>= 0 and less than 1 day) for each element. | |
Number of microseconds (>= 0 and less than 1 second) for each element. | |
Number of nanoseconds (>= 0 and less than 1 microsecond) for each element. | |
Return a dataframe of the components (days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) of the Timedeltas. | |
Tries to return a string representing a frequency guess, generated by infer_freq. |
Conversion
| Return Timedelta Array/Index as object ndarray of datetime.timedelta objects. |
| Create a Series with both index and values equal to the index keys. |
| Perform round operation on the data to the specified freq. |
| Perform floor operation on the data to the specified freq. |
| Perform ceil operation on the data to the specified freq. |
| Create a DataFrame with a column containing the Index. |
Methods
| Return the mean value of the Array. |
PeriodIndex
| Immutable ndarray holding ordinal values indicating regular periods in time. |
Properties
The days of the period. | |
The day of the week with Monday=0, Sunday=6. | |
The day of the week with Monday=0, Sunday=6. | |
The ordinal day of the year. | |
The ordinal day of the year. | |
The number of days in the month. | |
The number of days in the month. | |
Return the frequency object if it is set, otherwise None. | |
Return the frequency object as a string if its set, otherwise None. | |
The hour of the period. | |
Logical indicating if the date belongs to a leap year. | |
The minute of the period. | |
The month as January=1, December=12. | |
The quarter of the date. | |
The second of the period. | |
The week ordinal of the year. | |
The day of the week with Monday=0, Sunday=6. | |
The week ordinal of the year. | |
The year of the period. |
Methods
| Convert the PeriodArray to the specified frequency freq. |
| Convert to Index using specified date_format. |
| Cast to DatetimeArray/Index. |
© 2008–2021, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.3.4/reference/indexing.html