Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.Index

class pandas.Index[source]

Immutable ndarray implementing an ordered, sliceable set. The basic object storing axis labels for all pandas objects

Parameters:

data : array-like (1-dimensional)

dtype : NumPy dtype (default: object)

copy : bool

Make a copy of input ndarray

name : object

Name to be stored in the index

tupleize_cols : bool (default: True)

When True, attempt to create a MultiIndex if possible

Notes

An Index instance can only contain hashable objects

Attributes

T return the transpose, which is by definition self
asi8
base return the base object if the memory of the underlying data is
data return the data pointer of the underlying data
dtype
dtype_str
flags
has_duplicates
hasnans
inferred_type
is_all_dates
is_monotonic alias for is_monotonic_increasing (deprecated)
is_monotonic_decreasing return if the index is monotonic decreasing (only equal or
is_monotonic_increasing return if the index is monotonic increasing (only equal or
is_unique
itemsize return the size of the dtype of the item of the underlying data
name
names
nbytes return the number of bytes in the underlying data
ndim return the number of dimensions of the underlying data,
nlevels
shape return a tuple of the shape of the underlying data
size return the number of elements in the underlying data
strides return the strides of the underlying data
values return the underlying data as an ndarray

Methods

all(\*args, \*\*kwargs) Return whether all elements are True
any(\*args, \*\*kwargs) Return whether any element is True
append(other) Append a collection of Index options together
argmax([axis]) return a ndarray of the maximum argument indexer
argmin([axis]) return a ndarray of the minimum argument indexer
argsort(\*args, \*\*kwargs) Returns the indices that would sort the index and its underlying data.
asof(label) For a sorted index, return the most recent label up to and including the passed label.
asof_locs(where, mask) where : array of timestamps
astype(dtype[, copy]) Create an Index with values cast to dtypes.
copy([name, deep, dtype]) Make a copy of this object.
delete(loc) Make new Index with passed location(-s) deleted
difference(other) Return a new Index with elements from the index that are not in other.
drop(labels[, errors]) Make new Index with passed list of labels deleted
drop_duplicates(\*args, \*\*kwargs) Return Index with duplicate values removed
dropna([how]) Return Index without NA/NaN values
duplicated(\*args, \*\*kwargs) Return boolean np.ndarray denoting duplicate values
equals(other) Determines if two Index objects contain the same elements.
factorize([sort, na_sentinel]) Encode the object as an enumerated type or categorical variable
fillna([value, downcast]) Fill NA/NaN values with the specified value
format([name, formatter]) Render a string representation of the Index
get_duplicates()
get_indexer(target[, method, limit, tolerance]) Compute indexer and mask for new index given the current index.
get_indexer_for(target, \*\*kwargs) guaranteed return of an indexer even when non-unique
get_indexer_non_unique(target) return an indexer suitable for taking from a non unique index
get_level_values(level) Return vector of label values for requested level, equal to the length
get_loc(key[, method, tolerance]) Get integer location for requested label
get_slice_bound(label, side, kind) Calculate slice bound that corresponds to given label.
get_value(series, key) Fast lookup of value from 1-dimensional ndarray.
get_values() return the underlying data as an ndarray
groupby(values) Group the index labels by a given array of values.
holds_integer()
identical(other) Similar to equals, but check that other comparable attributes are
insert(loc, item) Make new Index inserting new item at location.
intersection(other) Form the intersection of two Index objects.
is_(other) More flexible, faster check like is but that works through views
is_boolean()
is_categorical()
is_floating()
is_integer()
is_lexsorted_for_tuple(tup)
is_mixed()
is_numeric()
is_object()
is_type_compatible(kind)
isin(values[, level]) Compute boolean array of whether each index value is found in the passed set of values.
item() return the first element of the underlying data as a python
join(other[, how, level, return_indexers]) this is an internal non-public method
map(mapper) Apply mapper function to its values.
max() The maximum value of the object
memory_usage([deep]) Memory usage of my values
min() The minimum value of the object
nunique([dropna]) Return number of unique elements in the object.
order([return_indexer, ascending]) Return sorted copy of Index
putmask(mask, value) return a new Index of the values set with the mask
ravel([order]) return an ndarray of the flattened values of the underlying data
reindex(target[, method, level, limit, ...]) Create index with target’s values (move/add/delete values as necessary)
rename(name[, inplace]) Set new names on index.
repeat(n, \*args, \*\*kwargs) Repeat elements of an Index.
reshape(\*args, \*\*kwargs) NOT IMPLEMENTED: do not call this method, as reshaping is not supported for Index objects and will raise an error.
searchsorted(key[, side, sorter]) Find indices where elements should be inserted to maintain order.
set_names(names[, level, inplace]) Set new names on index.
set_value(arr, key, value) Fast lookup of value from 1-dimensional ndarray.
shift([periods, freq]) Shift Index containing datetime objects by input number of periods and
slice_indexer([start, end, step, kind]) For an ordered Index, compute the slice indexer for input labels and
slice_locs([start, end, step, kind]) Compute slice locations for input labels.
sort(\*args, \*\*kwargs)
sort_values([return_indexer, ascending]) Return sorted copy of Index
sortlevel([level, ascending, sort_remaining]) For internal compatibility with with the Index API
str alias of StringMethods
summary([name])
sym_diff(\*args, \*\*kwargs)
symmetric_difference(other[, result_name]) Compute the symmetric difference of two Index objects.
take(indices[, axis, allow_fill, fill_value]) return a new %(klass)s of the values selected by the indices
to_datetime([dayfirst]) DEPRECATED: use pandas.to_datetime() instead.
to_native_types([slicer]) slice and dice then format
to_series(\*\*kwargs) Create a Series with both index and values equal to the index keys
tolist() return a list of the Index values
transpose(\*args, \*\*kwargs) return the transpose, which is by definition self
union(other) Form the union of two Index objects and sorts if possible.
unique() Return Index of unique values in the object.
value_counts([normalize, sort, ascending, ...]) Returns object containing counts of unique values.
view([cls])
where(cond[, other])

New in version 0.19.0.

Scroll To Top