Detail: IndexGO: Method#

Overview: IndexGO: Method

IndexGO.__array__(dtype=None)#

Support the __array__ interface, returning an array of values.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.__array__()
[1024 2048 4096]
IndexGO.__array_ufunc__(ufunc, method, *args, **kwargs)#

Support for NumPy elements or arrays on the left hand of binary operators.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> np.array((0, 1, 0)) * ix
[   0 2048    0]
IndexGO.__bool__()#

Raises ValueError to prohibit ambiguous use of truthy evaluation.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> bool(ix)
ErrorNotTruthy('The truth value of a container is ambiguous. For a truthy indicator of non-empty status, use the `size` attribute.')
IndexGO.__copy__()#

Return shallow copy of this Index.

>>> import copy
>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> copy.copy(ix)
<IndexGO: x>
a
b
c
d
e
<<U1>
IndexGO.__deepcopy__(memo)#
>>> import copy
>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> copy.deepcopy(ix)
<IndexGO: x>
a
b
c
d
e
<<U1>
IndexGO.__len__()#
>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> len(ix)
5
IndexGO.all(*, axis=0, skipna=True, out=None)#

Logical and over values along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((0, 1024, -2048, 4096))
>>> ix
<IndexGO>
0
1024
-2048
4096
<int64>
>>> ix.all()
False
IndexGO.any(*, axis=0, skipna=True, out=None)#

Logical or over values along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((0, 1024, -2048, 4096))
>>> ix
<IndexGO>
0
1024
-2048
4096
<int64>
>>> ix.any()
True
IndexGO.append(value, /)#

Append a value to this Index. Note: if the appended value not permitted by a specific Index subclass, this will raise and the caller will need to derive a new index type.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.append('f')
>>> ix
<IndexGO: x>
a
b
c
d
e
f
<<U1>
IndexGO.astype(dtype, /)#

Return an Index with type determined by dtype argument. If a datetime64 dtype is provided, the appropriate Index subclass will be returned. Note that for Index, this is a simple function, whereas for IndexHierarchy, this is an interface exposing both a callable and a getitem interface.

Parameters:

dtype – A value suitable for specyfying a NumPy dtype, such as a Python type (float), NumPy array protocol strings (‘f8’), or a dtype instance.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.astype(float)
<IndexGO: y>
1024.0
2048.0
4096.0
<float64>
IndexGO.copy()#

Return shallow copy of this Index.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.copy()
<IndexGO: y>
1024
2048
4096
<int64>
IndexGO.cumprod(*, axis=0, skipna=True)#

Return the cumulative product over the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.cumprod()
[      1024    2097152 8589934592]
IndexGO.cumsum(*, axis=0, skipna=True)#

Return the cumulative sum over the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.cumsum()
[1024 3072 7168]
IndexGO.difference(*others)#

Perform difference with another Index, container, or NumPy array. Retains order.

>>> ix1 = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix1
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix2 = sf.IndexGO(('c', 'd', 'e', 'f'), name='y')
>>> ix2
<IndexGO: y>
c
d
e
f
<<U1>
>>> ix1.difference(ix2)
<IndexGO>
a
b
<<U1>
IndexGO.dropfalsy()#

Return a new Index after removing values of NaN or None.

>>> ix = sf.IndexGO(('', 'b', 'c', 'd'))
>>> ix
<IndexGO>

b
c
d
<<U1>
>>> ix.dropfalsy()
<IndexGO>
b
c
d
<<U1>
IndexGO.dropna()#

Return a new Index after removing values of NaN or None.

>>> ix = sf.IndexGO((None, 'A', 1024, True), name='x')
>>> ix
<IndexGO: x>
None
A
1024
True
<object>
>>> ix.dropna()
<IndexGO: x>
A
1024
True
<object>
IndexGO.equals(other, /, *, compare_name=False, compare_dtype=False, compare_class=False, skipna=True)#

Return a bool from comparison to any other object.

Parameters:
  • compare_name – Include equality of the container’s name (and all composed containers) in the comparison.

  • compare_dtype – Include equality of the container’s dtype (and all composed containers) in the comparison.

  • compare_class – Include equality of the container’s class (and all composed containers) in the comparison.

  • skipna – If True, comparisons between missing values are equal.

>>> ix1 = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix1
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix2 = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix2
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix1.equals(ix2)
False
IndexGO.extend(values, /)#

Append multiple values :param values: can be a generator.

>>> ix1 = sf.IndexGO(('a', 'b', 'c'), name='x')
>>> ix1
<IndexGO: x>
a
b
c
<<U1>
>>> ix2 = sf.IndexGO(('d', 'e', 'f'))
>>> ix2
<IndexGO>
d
e
f
<<U1>
>>> ix1.extend(ix2)
>>> ix1
<IndexGO: x>
a
b
c
d
e
f
<<U1>
IndexGO.fillfalsy(value, /)#

Return an Index with replacing falsy values with the supplied value.

Parameters:

value – Value to be used to replace missing values (NaN or None).

>>> ix = sf.IndexGO(('', 'b', 'c', 'd'))
>>> ix
<IndexGO>

b
c
d
<<U1>
>>> ix.fillfalsy('A')
<IndexGO>
A
b
c
d
<<U1>
IndexGO.fillna(value, /)#

Return an Index with replacing null (NaN or None) with the supplied value.

Parameters:

value – Value to be used to replace missing values (NaN or None).

>>> ix = sf.IndexGO((None, 'A', 1024, True), name='x')
>>> ix
<IndexGO: x>
None
A
1024
True
<object>
>>> ix.fillna(0)
<IndexGO: x>
0
A
1024
True
<object>
IndexGO.head(count=5, /)#

Return a Index consisting only of the top elements as specified by count.

Parameters:

count – Number of elements to be returned from the top of the Index

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.head(2)
<IndexGO: x>
a
b
<<U1>
IndexGO.iloc_searchsorted(values, /, *, side_left=True)#

Given a sorted Series, return the iloc (integer) position(s) at which insertion in values would retain sort order.

Parameters:
  • values – a single value, or iterable of values.

  • side_left – If True, the index of the first suitable location found is given, else return the last such index. If matching an existing value, side_left==True will return that position, side_left==Right will return the next position (or the length).

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.iloc_searchsorted('c')
2
IndexGO.intersection(*others)#

Perform intersection with one or many Index, container, or NumPy array. Identical comparisons retain order.

>>> ix1 = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix1
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix2 = sf.IndexGO(('c', 'd', 'e', 'f'), name='y')
>>> ix2
<IndexGO: y>
c
d
e
f
<<U1>
>>> ix1.intersection(ix2)
<IndexGO>
c
d
e
<<U1>
IndexGO.isfalsy()#

Return a same-shaped, Boolean ndarray indicating which values are falsy.

>>> ix = sf.IndexGO(('a', '', None, 0, np.nan, 'b'))
>>> ix.isfalsy()
[False  True  True  True  True False]
IndexGO.isin(other, /)#

Return a Boolean array showing True where a label is found in other. If other is a multidimensional array, it is flattened.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.isin(('a', 'e'))
[ True False False False  True]
IndexGO.isna()#

Return a same-shaped, Boolean ndarray indicating which values are NaN or None.

>>> ix = sf.IndexGO(('a', '', None, 0, np.nan, 'b'))
>>> ix.isna()
[False False  True False  True False]
IndexGO.label_widths_at_depth(depth_level=0, /)#

A generator of pairs, where each pair is the label and the contiguous count of that label found at the depth specified by depth_level.

Parameters:

depth_level – a depth level, starting from zero.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> tuple(ix.label_widths_at_depth(0))
((np.str_('a'), 1), (np.str_('b'), 1), (np.str_('c'), 1), (np.str_('d'), 1), (np.str_('e'), 1))
IndexGO.level_add(level, /, *, index_constructor=None)#

Return an IndexHierarchy with an added root level.

Parameters:
  • level – A hashable to used as the new root.

  • *

  • index_constructor

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.level_add('A')
<IndexHierarchyGO: y>
A                     1024
A                     2048
A                     4096
<<U1>                 <int64>
IndexGO.loc_searchsorted(values, /, *, side_left=True, fill_value=nan)#

Given a sorted Series, return the loc (label) position(s) at which insertion in values would retain sort order.

Parameters:
  • values – a single value, or iterable of values.

  • side_left – If True, the index of the first suitable location found is given, else return the last such index. If matching an existing value, side_left==True will return that position, side_left==Right will return the next position (or the length).

  • fill_value – A value to be used to fill the label beyond the last label.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.loc_searchsorted('c')
c
IndexGO.loc_to_iloc(key, /)#

Given a label (loc) style key (either a label, a list of labels, a slice, or a Boolean selection), return the index position (iloc) style key. Keys that are not found will raise a KeyError or a sf.LocInvalid error.

Parameters:

key – a label key.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.loc_to_iloc('d')
3
>>> ix.loc_to_iloc(['a', 'e'])
[0 4]
>>> ix.loc_to_iloc(slice('c', None))
slice(2, None, None)
IndexGO.max(*, axis=0, skipna=True, out=None)#

Return the maximum along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.max()
4096
IndexGO.mean(*, axis=0, skipna=True, out=None)#

Return the mean along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.mean()
2389.3333333333335
IndexGO.median(*, axis=0, skipna=True, out=None)#

Return the median along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.median()
2048.0
IndexGO.min(*, axis=0, skipna=True, out=None)#

Return the minimum along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.min()
1024
IndexGO.notfalsy()#

Return a same-shaped, Boolean ndarray indicating which values are falsy.

>>> ix = sf.IndexGO(('a', '', None, 0, np.nan, 'b'))
>>> ix.notfalsy()
[ True False False False False  True]
IndexGO.notna()#

Return a same-shaped, Boolean ndarray indicating which values are NaN or None.

>>> ix = sf.IndexGO(('a', '', None, 0, np.nan, 'b'))
>>> ix.notna()
[ True  True False  True False  True]
IndexGO.prod(*, axis=0, skipna=True, allna=1, out=None)#

Return the product along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.prod()
8589934592
IndexGO.relabel(mapper, /)#

Return a new Index with labels replaced by the callable or mapping; order will be retained. If a mapping is used, the mapping need not map all origin keys.

>>> ix = sf.IndexGO(('a', 'b', 'c'), name='x')
>>> ix
<IndexGO: x>
a
b
c
<<U1>
>>> ix.relabel(dict(a='x', c='y'))
<IndexGO: x>
x
b
y
<<U1>
>>> ix.relabel(lambda l: l.upper() if l != 'b' else l)
<IndexGO: x>
A
b
C
<<U1>
IndexGO.rename(name, /)#

Return a new Frame with an updated name attribute.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.rename('y')
<IndexGO: y>
a
b
c
d
e
<<U1>
IndexGO.roll(shift)#

Return an Index with values rotated forward and wrapped around (with a postive shift) or backward and wrapped around (with a negative shift).

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.roll(2)
<IndexGO: x>
d
e
a
b
c
<<U1>
IndexGO.sample(count=1, *, seed=None)#

Randomly (optionally made deterministic with a fixed seed) extract items from the container to return a subset of the container.

Parameters:
  • select. (Number of elements to) –

  • selection. (Initial state of random) –

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.sample(2, seed=0)
<IndexGO: x>
a
c
<<U1>
IndexGO.sort(*, ascending=True, kind='mergesort', key=None)#

Return a new Index with the labels sorted.

Parameters:
  • ascending – If True, sort in ascending order; if False, sort in descending order.

  • kind – Name of the sort algorithm as passed to NumPy.

  • key – A function that is used to pre-process the selected columns or rows and derive new values to sort by.

>>> ix = sf.IndexGO(('b', 'e', 'c', 'a', 'd'), name='x')
>>> ix
<IndexGO: x>
b
e
c
a
d
<<U1>
>>> ix.sort()
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.sort(ascending=False)
<IndexGO: x>
e
d
c
b
a
<<U1>
IndexGO.std(*, axis=0, skipna=True, ddof=0, out=None)#

Return the standard deviaton along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.std()
1277.1523880188386
IndexGO.sum(*, axis=0, skipna=True, allna=0, out=None)#

Sum values along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.sum()
7168
IndexGO.tail(count=5, /)#

Return a Index consisting only of the bottom elements as specified by count.

Parameters:

count – Number of elements to be returned from the bottom of the Index

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.tail(2)
<IndexGO: x>
d
e
<<U1>
IndexGO.union(*others)#

Perform union with another Index, container, or NumPy array. Identical comparisons retain order.

>>> ix1 = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix1
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix2 = sf.IndexGO(('c', 'd', 'e', 'f'), name='y')
>>> ix2
<IndexGO: y>
c
d
e
f
<<U1>
>>> ix1.union(ix2)
<IndexGO>
a
b
c
d
e
f
<<U1>
IndexGO.unique(depth_level=0, /, *, order_by_occurrence=False)#

Return a NumPy array of unique values.

Parameters:
  • depth_level – defaults to 0 for for a 1D Index.

  • order_by_occurrence – for 1D indices, this argument is a no-op. Provided for compatibility with IndexHierarchy.

Returns:

numpy.ndarray

>>> ix = sf.IndexGO((None, 'A', 1024, True), name='x')
>>> ix
<IndexGO: x>
None
A
1024
True
<object>
>>> ix.unique()
[None 'A' 1024 True]
IndexGO.values_at_depth(depth_level=0, /)#

Return an NP array for the depth_level specified.

>>> ix = sf.IndexGO(('a', 'b', 'c', 'd', 'e'), name='x')
>>> ix
<IndexGO: x>
a
b
c
d
e
<<U1>
>>> ix.values_at_depth(0)
['a' 'b' 'c' 'd' 'e']
IndexGO.var(*, axis=0, skipna=True, ddof=0, out=None)#

Return the variance along the specified axis.

Parameters:
  • axis – Axis, defaulting to axis 0.

  • skipna – Skip missing (NaN) values, defaulting to True.

>>> ix = sf.IndexGO((1024, 2048, 4096), name='y')
>>> ix
<IndexGO: y>
1024
2048
4096
<int64>
>>> ix.var()
1631118.222222222

IndexGO: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Regular Expression | Accessor Hashlib | Accessor Type Clinic