pandas.
Index
Immutable ndarray implementing an ordered, sliceable set. The basic object storing axis labels for all pandas objects.
If dtype is None, we find the dtype that best fits the data. If an actual dtype is provided, we coerce to that dtype if it’s safe. Otherwise, an error will be raised.
Make a copy of input ndarray.
Name to be stored in the index.
When True, attempt to create a MultiIndex if possible.
See also
RangeIndex
Index implementing a monotonic integer range.
CategoricalIndex
Index of Categorical s.
Categorical
MultiIndex
A multi-level, or hierarchical Index.
IntervalIndex
An Index of Interval s.
Interval
DatetimeIndex
Index of datetime64 data.
TimedeltaIndex
Index of timedelta64 data.
PeriodIndex
Index of Period data.
Int64Index
A special case of Index with purely integer labels.
UInt64Index
A special case of Index with purely unsigned integer labels.
Float64Index
A special case of Index with purely float labels.
Notes
An Index instance can only contain hashable objects
Examples
>>> pd.Index([1, 2, 3]) Int64Index([1, 2, 3], dtype='int64')
>>> pd.Index(list('abc')) Index(['a', 'b', 'c'], dtype='object')
Attributes
T
Return the transpose, which is by definition self.
array
The ExtensionArray of the data backing this Series or Index.
asi8
Integer representation of the values.
dtype
Return the dtype object of the underlying data.
has_duplicates
Check if the Index has duplicate values.
hasnans
Return if I have any nans; enables various perf speedups.
inferred_type
Return a string of the type inferred from the values.
is_all_dates
Whether or not the index values only consist of dates.
is_monotonic
Alias for is_monotonic_increasing.
is_monotonic_decreasing
Return if the index is monotonic decreasing (only equal or decreasing) values.
is_monotonic_increasing
Return if the index is monotonic increasing (only equal or increasing) values.
is_unique
Return if the index has unique values.
name
Return Index or MultiIndex name.
nbytes
Return the number of bytes in the underlying data.
ndim
Number of dimensions of the underlying data, by definition 1.
nlevels
Number of levels.
shape
Return a tuple of the shape of the underlying data.
size
Return the number of elements in the underlying data.
values
Return an array representing the data in the Index.
empty
names
Methods
all(*args, **kwargs)
all
Return whether all elements are True.
any(*args, **kwargs)
any
Return whether any element is True.
append(other)
append
Append a collection of Index options together.
argmax([axis, skipna])
argmax
Return int position of the largest value in the Series.
argmin([axis, skipna])
argmin
Return int position of the smallest value in the Series.
argsort(*args, **kwargs)
argsort
Return the integer indices that would sort the index.
asof(label)
asof
Return the label from the index, or, if not present, the previous one.
asof_locs(where, mask)
asof_locs
Return the locations (indices) of labels in the index.
astype(dtype[, copy])
astype
Create an Index with values cast to dtypes.
copy([name, deep, dtype, names])
copy
Make a copy of this object.
delete(loc)
delete
Make new Index with passed location(-s) deleted.
difference(other[, sort])
difference
Return a new Index with elements of index not in other.
drop(labels[, errors])
drop
Make new Index with passed list of labels deleted.
drop_duplicates([keep])
drop_duplicates
Return Index with duplicate values removed.
droplevel([level])
droplevel
Return index with requested level(s) removed.
dropna([how])
dropna
Return Index without NA/NaN values.
duplicated([keep])
duplicated
Indicate duplicate index values.
equals(other)
equals
Determine if two Index object are equal.
factorize([sort, na_sentinel])
factorize
Encode the object as an enumerated type or categorical variable.
fillna([value, downcast])
fillna
Fill NA/NaN values with the specified value.
format([name, formatter, na_rep])
format
Render a string representation of the Index.
get_indexer(target[, method, limit, tolerance])
get_indexer
Compute indexer and mask for new index given the current index.
get_indexer_for(target, **kwargs)
get_indexer_for
Guaranteed return of an indexer even when non-unique.
get_indexer_non_unique(target)
get_indexer_non_unique
get_level_values(level)
get_level_values
Return an Index of values for requested level.
get_loc(key[, method, tolerance])
get_loc
Get integer location, slice or boolean mask for requested label.
get_slice_bound(label, side, kind)
get_slice_bound
Calculate slice bound that corresponds to given label.
get_value(series, key)
get_value
Fast lookup of value from 1-dimensional ndarray.
groupby(values)
groupby
Group the index labels by a given array of values.
holds_integer()
holds_integer
Whether the type is an integer type.
identical(other)
identical
Similar to equals, but checks that object attributes and types are also equal.
insert(loc, item)
insert
Make new Index inserting new item at location.
intersection(other[, sort])
intersection
Form the intersection of two Index objects.
is_(other)
is_
More flexible, faster check like is but that works through views.
is
is_boolean()
is_boolean
Check if the Index only consists of booleans.
is_categorical()
is_categorical
Check if the Index holds categorical data.
is_floating()
is_floating
Check if the Index is a floating type.
is_integer()
is_integer
Check if the Index only consists of integers.
is_interval()
is_interval
Check if the Index holds Interval objects.
is_mixed()
is_mixed
Check if the Index holds data with mixed data types.
is_numeric()
is_numeric
Check if the Index only consists of numeric data.
is_object()
is_object
Check if the Index is of the object dtype.
is_type_compatible(kind)
is_type_compatible
Whether the index type is compatible with the provided type.
isin(values[, level])
isin
Return a boolean array where the index values are in values.
isna()
isna
Detect missing values.
isnull()
isnull
item()
item
Return the first element of the underlying data as a python scalar.
join(other[, how, level, return_indexers, sort])
join
Compute join_index and indexers to conform data structures to the new index.
map(mapper[, na_action])
map
Map values using input correspondence (a dict, Series, or function).
max([axis, skipna])
max
Return the maximum value of the Index.
memory_usage([deep])
memory_usage
Memory usage of the values.
min([axis, skipna])
min
Return the minimum value of the Index.
notna()
notna
Detect existing (non-missing) values.
notnull()
notnull
nunique([dropna])
nunique
Return number of unique elements in the object.
putmask(mask, value)
putmask
Return a new Index of the values set with the mask.
ravel([order])
ravel
Return an ndarray of the flattened values of the underlying data.
reindex(target[, method, level, limit, …])
reindex
Create index with target’s values.
rename(name[, inplace])
rename
Alter Index or MultiIndex name.
repeat(repeats[, axis])
repeat
Repeat elements of a Index.
searchsorted(value[, side, sorter])
searchsorted
Find indices where elements should be inserted to maintain order.
set_names(names[, level, inplace])
set_names
Set Index or MultiIndex name.
set_value(arr, key, value)
set_value
(DEPRECATED) Fast lookup of value from 1-dimensional ndarray.
shift([periods, freq])
shift
Shift index by desired number of time frequency increments.
slice_indexer([start, end, step, kind])
slice_indexer
Compute the slice indexer for input labels and step.
slice_locs([start, end, step, kind])
slice_locs
Compute slice locations for input labels.
sort(*args, **kwargs)
sort
Use sort_values instead.
sort_values([return_indexer, ascending, key])
sort_values
Return a sorted copy of the index.
sortlevel([level, ascending, sort_remaining])
sortlevel
For internal compatibility with with the Index API.
str
alias of pandas.core.strings.StringMethods
pandas.core.strings.StringMethods
symmetric_difference(other[, result_name, sort])
symmetric_difference
Compute the symmetric difference of two Index objects.
take(indices[, axis, allow_fill, fill_value])
take
Return a new Index of the values selected by the indices.
to_flat_index()
to_flat_index
Identity method.
to_frame([index, name])
to_frame
Create a DataFrame with a column containing the Index.
to_list()
to_list
Return a list of the values.
to_native_types([slicer])
to_native_types
Format specified values of self and return them.
to_numpy([dtype, copy, na_value])
to_numpy
A NumPy ndarray representing the values in this Series or Index.
to_series([index, name])
to_series
Create a Series with both index and values equal to the index keys.
tolist()
tolist
transpose(*args, **kwargs)
transpose
union(other[, sort])
union
Form the union of two Index objects.
unique([level])
unique
Return unique values in the index.
value_counts([normalize, sort, ascending, …])
value_counts
Return a Series containing counts of unique values.
where(cond[, other])
where
Replace values where the condition is False.
view