databricks.koalas.Index

class databricks.koalas.Index(data: Union[databricks.koalas.frame.DataFrame, list], dtype=None, name=None)[source]

Koalas Index that corresponds to pandas Index logically. This might hold Spark Column internally.

Variables
  • _kdf – The parent dataframe

  • _scol – Spark Column instance

Parameters
dataDataFrame or list

Index can be created by DataFrame or list

dtypedtype, default None

Data type to force. Only a single dtype is allowed. If None, infer

namename of index, hashable

See also

MultiIndex

A multi-level, or hierarchical, Index.

Examples

>>> ks.DataFrame({'a': ['a', 'b', 'c']}, index=[1, 2, 3]).index
Int64Index([1, 2, 3], dtype='int64')
>>> ks.DataFrame({'a': [1, 2, 3]}, index=list('abc')).index
Index(['a', 'b', 'c'], dtype='object')
>>> Index([1, 2, 3])
Int64Index([1, 2, 3], dtype='int64')
>>> Index(list('abc'))
Index(['a', 'b', 'c'], dtype='object')
__init__(data: Union[databricks.koalas.frame.DataFrame, list], dtype=None, name=None) → None[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(data[, dtype, name])

Initialize self.

all([axis])

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 Koalas 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()

Return Index with duplicate values removed.

droplevel(level)

Return index with requested level(s) removed.

dropna()

Return Index or MultiIndex without NA/NaN values

equals(other)

Determine if two Index objects contain the same elements.

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.

is_boolean()

Return if the current index type is a boolean type.

is_categorical()

Return if the current index type is a categorical type.

is_floating()

Return if the current index type is a floating type.

is_integer()

Return if the current index type is a integer type.

is_interval()

Return if the current index type is an interval type.

is_numeric()

Return if the current index type is a numeric type.

is_object()

Return if the current index type is a object type.

isin(values)

Check whether values are contained in Series.

isna()

Detect existing (non-missing) values.

isnull()

Detect existing (non-missing) values.

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([ascending])

Return a sorted copy of the index.

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.

toPandas()

Return a pandas Index.

to_frame([index, name])

Create a DataFrame with a column containing the Index.

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.

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.

Attributes

T

Return the transpose, For index, It will be index itself.

dtype

Return the dtype object of the underlying data.

empty

Returns true if the current object is empty.

has_duplicates

If index has duplicates, return True, otherwise False.

hasnans

Return True if it has any missing values.

is_all_dates

Return if all data types of the index are datetime.

is_monotonic

Return boolean if values in the object are monotonically increasing.

is_monotonic_decreasing

Return boolean if values in the object are monotonically decreasing.

is_monotonic_increasing

Return boolean if values in the object are monotonically increasing.

name

Return name of the Index.

names

Return names of the Index.

ndim

Return an int representing the number of array dimensions.

nlevels

Number of levels in Index & MultiIndex.

shape

Return a tuple of the shape of the underlying data.

size

Return an int representing the number of elements in this object.

spark_column

Spark Column object representing the Series/Index.

spark_type

Returns the data type as defined by Spark, as a Spark DataType object.

values

Return an array representing the data in the Index.