pyspark.pandas.Index¶
-
class
pyspark.pandas.
Index
¶ pandas-on-Spark Index that corresponds to pandas Index logically. This might hold Spark Column internally.
- Parameters
- dataarray-like (1-dimensional)
- dtypedtype, default None
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.
- copybool
Make a copy of input ndarray.
- nameobject
Name to be stored in the index.
- tupleize_colsbool (default: True)
When True, attempt to create a MultiIndex if possible.
See also
MultiIndex
A multi-level, or hierarchical, Index.
DatetimeIndex
Index of datetime64 data.
Int64Index
A special case of
Index
with purely integer labels.Float64Index
A special case of
Index
with purely float labels.
Examples
>>> ps.DataFrame({'a': ['a', 'b', 'c']}, index=[1, 2, 3]).index Int64Index([1, 2, 3], dtype='int64')
>>> ps.DataFrame({'a': [1, 2, 3]}, index=list('abc')).index Index(['a', 'b', 'c'], dtype='object')
>>> ps.Index([1, 2, 3]) Int64Index([1, 2, 3], dtype='int64')
>>> ps.Index(list('abc')) Index(['a', 'b', 'c'], dtype='object')
From a Series:
>>> s = ps.Series([1, 2, 3], index=[10, 20, 30]) >>> ps.Index(s) Int64Index([1, 2, 3], dtype='int64')
From an Index:
>>> idx = ps.Index([1, 2, 3]) >>> ps.Index(idx) Int64Index([1, 2, 3], dtype='int64')
Methods
all
([axis, skipna])Return whether all elements are True.
any
([axis])Return whether any element is True.
append
(other)Append a collection of Index options together.
argmax
()Return a maximum argument indexer.
argmin
()Return a minimum argument indexer.
asof
(label)Return the label from the index, or, if not present, the previous one.
astype
(dtype)Cast a pandas-on-Spark object to a specified dtype
dtype
.copy
([name, deep])Make a copy of this object.
delete
(loc)Make new Index with passed location(-s) deleted.
difference
(other[, sort])Return a new Index with elements from the index that are not in other.
drop
(labels)Make new Index with passed list of labels deleted.
drop_duplicates
([keep])Return Index with duplicate values removed.
droplevel
(level)Return index with requested level(s) removed.
dropna
([how])Return Index or MultiIndex without NA/NaN values
equals
(other)Determine if two Index objects contain the same elements.
factorize
([sort, na_sentinel])Encode the object as an enumerated type or categorical variable.
fillna
(value)Fill NA/NaN values with the specified value.
get_level_values
(level)Return Index if a valid level is given.
holds_integer
()Whether the type is an integer type.
identical
(other)Similar to equals, but check that other comparable attributes are also equal.
insert
(loc, item)Make new Index inserting new item at location.
intersection
(other)Form the intersection of two Index objects.
Return if the current index type is a boolean type.
Return if the current index type is a categorical type.
Return if the current index type is a floating type.
Return if the current index type is a integer type.
Return if the current index type is an interval type.
Return if the current index type is a numeric type.
Return if the current index type is a object type.
is_type_compatible
(kind)Whether the index type is compatible with the provided type.
isin
(values)Check whether values are contained in Series or Index.
isna
()Detect existing (non-missing) values.
isnull
()Detect existing (non-missing) values.
item
()Return the first element of the underlying data as a python scalar.
map
(mapper[, na_action])Map values using input correspondence (a dict, Series, or function).
max
()Return the maximum value of the Index.
min
()Return the minimum value of the Index.
notna
()Detect existing (non-missing) values.
notnull
()Detect existing (non-missing) values.
nunique
([dropna, approx, rsd])Return number of unique elements in the object.
rename
(name[, inplace])Alter Index or MultiIndex name.
repeat
(repeats)Repeat elements of a Index/MultiIndex.
set_names
(names[, level, inplace])Set Index or MultiIndex name.
shift
([periods, fill_value])Shift Series/Index by desired number of periods.
sort
(*args, **kwargs)Use sort_values instead.
sort_values
([return_indexer, ascending])Return a sorted copy of the index, and optionally return the indices that sorted the index itself.
symmetric_difference
(other[, result_name, sort])Compute the symmetric difference of two Index objects.
take
(indices)Return the elements in the given positional indices along an axis.
to_frame
([index, name])Create a DataFrame with a column containing the Index.
to_list
()Return a list of the values.
to_numpy
([dtype, copy])A NumPy ndarray representing the values in this Index or MultiIndex.
to_pandas
()Return a pandas Index.
to_series
([name])Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index.
tolist
()Return a list of the values.
transpose
()Return the transpose, For index, It will be index itself.
union
(other[, sort])Form the union of two Index objects.
unique
([level])Return unique values in the index.
value_counts
([normalize, sort, ascending, …])Return a Series containing counts of unique values.
view
()this is defined as a copy with the same identity
Attributes
Return the transpose, For index, It will be index itself.
asi8
Integer representation of the values.
Return the dtype object of the underlying data.
Returns true if the current object is empty.
If index has duplicates, return True, otherwise False.
Return True if it has any missing values.
Return a string of the type inferred from the values.
Return if all data types of the index are datetime.
Return boolean if values in the object are monotonically increasing.
Return boolean if values in the object are monotonically decreasing.
Return boolean if values in the object are monotonically increasing.
Return if the index has unique values.
Return name of the Index.
Return names of the Index.
Return an int representing the number of array dimensions.
Number of levels in Index & MultiIndex.
Return a tuple of the shape of the underlying data.
Return an int representing the number of elements in this object.
Return an array representing the data in the Index.