databricks.koalas.
MultiIndex
Koalas MultiIndex that corresponds to pandas MultiIndex logically. This might hold Spark Column internally.
_kdf – The parent dataframe
_scol – Spark Column instance
See also
Index
A single-level Index.
Examples
>>> ks.DataFrame({'a': ['a', 'b', 'c']}, index=[[1, 2, 3], [4, 5, 6]]).index MultiIndex([(1, 4), (2, 5), (3, 6)], )
>>> ks.DataFrame({'a': [1, 2, 3]}, index=[list('abc'), list('def')]).index MultiIndex([('a', 'd'), ('b', 'e'), ('c', 'f')], )
__init__
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(kdf)
Initialize self.
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()
argmax
Return a maximum argument indexer.
argmin()
argmin
Return a minimum argument indexer.
asof(label)
asof
Return the label from the index, or, if not present, the previous one.
astype(dtype)
astype
Cast a Koalas object to a specified dtype dtype.
dtype
copy([deep])
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 from the index that are not in other.
drop(codes[, level])
drop
Make new MultiIndex with passed list of labels deleted
drop_duplicates()
drop_duplicates
Return Index with duplicate values removed.
droplevel(level)
droplevel
Return index with requested level(s) removed.
dropna()
dropna
Return Index or MultiIndex without NA/NaN values
equals(other)
equals
Determine if two Index objects contain the same elements.
fillna(value)
fillna
Fill NA/NaN values with the specified value.
from_arrays(arrays[, sortorder, names])
from_arrays
Convert arrays to MultiIndex.
from_product(iterables[, sortorder, names])
from_product
Make a MultiIndex from the cartesian product of multiple iterables.
from_tuples(tuples[, sortorder, names])
from_tuples
Convert list of tuples to MultiIndex.
get_level_values(level)
get_level_values
Return vector of label values for requested level, equal to the length of the index.
holds_integer()
holds_integer
Whether the type is an integer type.
identical(other)
identical
Similar to equals, but check that other comparable attributes are also equal.
is_boolean()
is_boolean
Return if the current index type is a boolean type.
is_categorical()
is_categorical
Return if the current index type is a categorical type.
is_floating()
is_floating
Return if the current index type is a floating type.
is_integer()
is_integer
Return if the current index type is a integer type.
is_interval()
is_interval
Return if the current index type is an interval type.
is_numeric()
is_numeric
Return if the current index type is a numeric type.
is_object()
is_object
Return if the current index type is a object type.
isin(values)
isin
Check whether values are contained in Series.
isna()
isna
Detect existing (non-missing) values.
isnull()
isnull
max()
max
Return the maximum value of the Index.
min()
min
Return the minimum value of the Index.
notna()
notna
notnull()
notnull
nunique([dropna])
nunique
Return number of unique elements in the object.
rename(name[, inplace])
rename
Alter Index or MultiIndex name.
repeat(repeats)
repeat
Repeat elements of a Index/MultiIndex.
set_names(names[, level, inplace])
set_names
Set Index or MultiIndex name.
shift([periods, fill_value])
shift
Shift Series/Index by desired number of periods.
sort(*args, **kwargs)
sort
Use sort_values instead.
sort_values([ascending])
sort_values
Return a sorted copy of the index.
swaplevel([i, j])
swaplevel
Swap level i with level j.
symmetric_difference(other[, result_name, sort])
symmetric_difference
Compute the symmetric difference of two MultiIndex objects.
take(indices)
take
Return the elements in the given positional indices along an axis.
toPandas()
toPandas
Return a pandas MultiIndex.
to_frame([index, name])
to_frame
Create a DataFrame with the levels of the MultiIndex as columns.
to_numpy([dtype, copy])
to_numpy
A NumPy ndarray representing the values in this Index or MultiIndex.
to_pandas()
to_pandas
to_series([name])
to_series
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()
transpose
Return the transpose, For index, It will be index itself.
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.
Attributes
T
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
is_all_dates always returns False for MultiIndex
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
levshape
A tuple with the length of each level.
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.