Detail: SeriesHE: Method

Overview: SeriesHE: Method

SeriesHE.__array__(dtype=None)

Support the __array__ interface, returning an array of values.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.__array__()
[10  2  8]
SeriesHE.__array_ufunc__(ufunc, method, *args, **kwargs)

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

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> np.array((0, 1, 0)) * s
<SeriesHE>
<Index>
a          0
b          2
c          0
<<U1>      <int64>
SeriesHE.__bool__()

Raises ValueError to prohibit ambiguous use of truethy evaluation.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> bool(s)
ValueError('The truth value of a container is ambiguous. For a truthy indicator of non-empty status, use the `size` attribute.')
SeriesHE.__deepcopy__(memo)
>>> import copy
>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> copy.deepcopy(s)
<SeriesHE>
<Index>
a          10
b          2
c          8
<<U1>      <int64>
SeriesHE.__len__()

Length of values.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> len(s)
3
SeriesHE.__round__(decimals=0)

Return a Series rounded to the given decimals. Negative decimals round to the left of the decimal point.

Parameters

decimals – number of decimals to round to.

Returns

Series

>>> s = sf.SeriesHE((10.235, 2.124, 8.734), index=('a', 'b', 'c'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          8.734
<<U1>      <float64>
>>> round(s, 1)
<SeriesHE>
<Index>
a          10.2
b          2.1
c          8.7
<<U1>      <float64>
SeriesHE.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.

>>> s = sf.SeriesHE((False, False, True), index=('a', 'b', 'c'))
>>> s.all()
False
SeriesHE.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.

>>> s = sf.SeriesHE((False, False, True), index=('a', 'b', 'c'))
>>> s.any()
True
SeriesHE.astype(dtype)

Return a Series with type determined by dtype argument. Note that for Series, this is a simple function, whereas for Frame, 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.

Returns

Series

>>> s = sf.SeriesHE((11, 1, None), index=('a', 'b', 'c'))
>>> s
<SeriesHE>
<Index>
a          11
b          1
c          None
<<U1>      <object>
>>> s.astype(float)
<SeriesHE>
<Index>
a          11.0
b          1.0
c          nan
<<U1>      <float64>
SeriesHE.clip(*, lower=None, upper=None)

Apply a clip operation to this Series. Note that clip operations can be applied to object types, but cannot be applied to non-numerical objects (e.g., strings, None)

Parameters
  • lower – value or Series to define the inclusive lower bound.

  • upper – value or Series to define the inclusive upper bound.

Returns

Series

>>> s = sf.SeriesHE((10.235, 2.124, 8.734), index=('a', 'b', 'c'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          8.734
<<U1>      <float64>
>>> s.clip(lower=2.5, upper=10.1)
<SeriesHE>
<Index>
a          10.1
b          2.5
c          8.734
<<U1>      <float64>
SeriesHE.corr(other)

Return the index-aligned correlation to the supplied Series.

Parameters

other – Series to be correlated with by selection on corresponding labels.

>>> s1 = sf.SeriesHE((10.235, 2.124, 8.734), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s1.corr(s2)
0.9977051066985494
SeriesHE.count(*, skipna=True, skipfalsy=False, unique=False, axis=0)

Return the count of non-NA, non-falsy, and/or unique elements.

Parameters
  • skipna – skip NA (NaN, None) values.

  • skipfalsy – skip falsu values (0, ‘’, False, None, NaN)

  • unique – Count unique items after optionally applying skipna or skipfalsy removals.

>>> s = sf.SeriesHE((8, 5, None, 8), index=('a', 'b', 'c', 'd'))
>>> s.count(skipna=True)
3
>>> s.count(unique=True)
2
SeriesHE.cov(other, *, ddof=1)

Return the index-aligned covariance to the supplied Series.

Parameters

ddof – Delta degrees of freedom, defaults to 1.

>>> s1 = sf.SeriesHE((10.235, 2.124, 8.734), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s1.cov(s2)
17.924999999999997
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.cumprod()
<SeriesHE>
<Index>
a          10
b          20
c          160
<<U1>      <int64>
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.cumsum()
<SeriesHE>
<Index>
a          10
b          12
c          20
<<U1>      <int64>
SeriesHE.drop_duplicated(*, exclude_first=False, exclude_last=False)

Return a Series with duplicated values removed.

Parameters
  • exclude_first – Boolean to select if the first duplicated value is excluded.

  • exclude_last – Boolean to select if the last duplicated value is excluded.

Returns

Series

>>> s = sf.SeriesHE((8, 5, None, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          None
d          8
<<U1>      <object>
>>> s.drop_duplicated()
<SeriesHE>
<Index>
b          5
c          None
<<U1>      <object>
SeriesHE.dropfalsy()

Return a new Series after removing values of falsy.

>>> s = sf.SeriesHE(('q', 'r', '', 's'), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          q
b          r
c
d          s
<<U1>      <<U1>
>>> s.dropfalsy()
<SeriesHE>
<Index>
a          q
b          r
d          s
<<U1>      <<U1>
SeriesHE.dropna()

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

>>> s = sf.SeriesHE((8, 5, None, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          None
d          8
<<U1>      <object>
>>> s.dropna()
<SeriesHE>
<Index>
a          8
b          5
d          8
<<U1>      <object>
SeriesHE.duplicated(*, exclude_first=False, exclude_last=False)

Return a same-sized Boolean Series that shows True for all values that are duplicated.

Parameters
  • exclude_first – Boolean to select if the first duplicated value is excluded.

  • exclude_last – Boolean to select if the last duplicated value is excluded.

Returns

numpy.ndarray

>>> s = sf.SeriesHE((8, 5, None, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          None
d          8
<<U1>      <object>
>>> s.duplicated()
<SeriesHE>
<Index>
a          True
b          False
c          False
d          True
<<U1>      <bool>
SeriesHE.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.

>>> s1 = sf.SeriesHE((10.235, 2.124, 8.734), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s1.equals(s2)
False
SeriesHE.fillfalsy(value)

Return a new Series after replacing falsy values with the supplied value. The value can be an element or Series.

Parameters

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

>>> s = sf.SeriesHE(('q', 'r', '', 's'), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          q
b          r
c
d          s
<<U1>      <<U1>
>>> s.fillfalsy('missing')
<SeriesHE>
<Index>
a          q
b          r
c          missing
d          s
<<U1>      <<U7>
SeriesHE.fillfalsy_backward(limit=0)

Return a new Series after feeding backward the last non-falsy observation across contiguous falsy values.

Parameters

limit – Set the maximum count of missing values (NaN or None) to be filled per contiguous region of missing vlaues. A value of 0 is equivalent to no limit.

>>> s = sf.SeriesHE(('', '', 'r', 's'), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a
b
c          r
d          s
<<U1>      <<U1>
>>> s.fillfalsy_backward()
<SeriesHE>
<Index>
a          r
b          r
c          r
d          s
<<U1>      <<U1>
SeriesHE.fillfalsy_forward(limit=0)

Return a new Series after feeding forward the last non-falsy observation across contiguous falsy values.

Parameters

limit – Set the maximum count of missing values (NaN or None) to be filled per contiguous region of missing vlaues. A value of 0 is equivalent to no limit.

>>> s = sf.SeriesHE(('p', 'q', '', ''), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          p
b          q
c
d
<<U1>      <<U1>
>>> s.fillfalsy_forward()
<SeriesHE>
<Index>
a          p
b          q
c          q
d          q
<<U1>      <<U1>
SeriesHE.fillfalsy_leading(value)

Return a new Series after filling leading (and only leading) falsy values with the supplied value.

Parameters

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

>>> s = sf.SeriesHE(('', '', 'r', 's'), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a
b
c          r
d          s
<<U1>      <<U1>
>>> s.fillfalsy_leading('missing')
<SeriesHE>
<Index>
a          missing
b          missing
c          r
d          s
<<U1>      <<U7>
SeriesHE.fillfalsy_trailing(value)

Return a new Series after filling trailing (and only trailing) falsy values with the supplied value.

Parameters

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

>>> s = sf.SeriesHE(('p', 'q', '', ''), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          p
b          q
c
d
<<U1>      <<U1>
>>> s.fillfalsy_trailing('missing')
<SeriesHE>
<Index>
a          p
b          q
c          missing
d          missing
<<U1>      <<U7>
SeriesHE.fillna(value)

Return a new Series after replacing NA (NaN or None) with the supplied value. The value can be an element or Series.

Parameters

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

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.fillna(0.0)
<SeriesHE>
<Index>
a          10.235
b          2.124
c          0.0
d          8.734
e          0.0
<<U1>      <float64>
SeriesHE.fillna_backward(limit=0)

Return a new Series after feeding backward the last non-null (NaN or None) observation across contiguous nulls.

Parameters

limit – Set the maximum count of missing values (NaN or None) to be filled per contiguous region of missing vlaues. A value of 0 is equivalent to no limit.

>>> s = sf.SeriesHE((np.nan, np.nan, 10.235, 2.124, 8.734), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          nan
b          nan
c          10.235
d          2.124
e          8.734
<<U1>      <float64>
>>> s.fillna_backward()
<SeriesHE>
<Index>
a          10.235
b          10.235
c          10.235
d          2.124
e          8.734
<<U1>      <float64>
SeriesHE.fillna_forward(limit=0)

Return a new Series after feeding forward the last non-null (NaN or None) observation across contiguous nulls.

Parameters

limit – Set the maximum count of missing values (NaN or None) to be filled per contiguous region of missing vlaues. A value of 0 is equivalent to no limit.

>>> s = sf.SeriesHE((10.235, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          8.734
d          nan
e          nan
<<U1>      <float64>
>>> s.fillna_forward()
<SeriesHE>
<Index>
a          10.235
b          2.124
c          8.734
d          8.734
e          8.734
<<U1>      <float64>
SeriesHE.fillna_leading(value)

Return a new Series after filling leading (and only leading) null (NaN or None) with the supplied value.

Parameters

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

>>> s = sf.SeriesHE((np.nan, np.nan, 10.235, 2.124, 8.734), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          nan
b          nan
c          10.235
d          2.124
e          8.734
<<U1>      <float64>
>>> s.fillna_leading(0.0)
<SeriesHE>
<Index>
a          0.0
b          0.0
c          10.235
d          2.124
e          8.734
<<U1>      <float64>
SeriesHE.fillna_trailing(value)

Return a new Series after filling trailing (and only trailing) null (NaN or None) with the supplied value.

Parameters

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

>>> s = sf.SeriesHE((10.235, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          8.734
d          nan
e          nan
<<U1>      <float64>
>>> s.fillna_trailing(0.0)
<SeriesHE>
<Index>
a          10.235
b          2.124
c          8.734
d          0.0
e          0.0
<<U1>      <float64>
SeriesHE.head(count=5)

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

Parameters

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

Returns

Series

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.head(2)
<SeriesHE>
<Index>
a          10.235
b          2.124
<<U1>      <float64>
SeriesHE.iloc_max(*, skipna=True)

Return the integer index corresponding to the maximum value.

Parameters

skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

Returns

int

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.iloc_max()
0
SeriesHE.iloc_min(*, skipna=True)

Return the integer index corresponding to the minimum value found.

Parameters

skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

Returns

int

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.iloc_min()
1
SeriesHE.iloc_notfalsy_first(*, fill_value=- 1)

Return the position corresponding to the first non-falsy (including nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a
b
c          19
d          34
e          None
<<U1>      <object>
>>> s.iloc_notfalsy_first()
2
SeriesHE.iloc_notfalsy_last(*, fill_value=- 1)

Return the position corresponding to the last non-falsy (including nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a
b
c          19
d          34
e          None
<<U1>      <object>
>>> s.iloc_notfalsy_last()
3
SeriesHE.iloc_notna_first(*, fill_value=- 1)

Return the position corresponding to the first not NA (None or nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          nan
b          2.124
c          8.734
d          nan
e          nan
<<U1>      <float64>
>>> s.iloc_notna_first()
1
SeriesHE.iloc_notna_last(*, fill_value=- 1)

Return the position corresponding to the last not NA (None or nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          nan
b          2.124
c          8.734
d          nan
e          nan
<<U1>      <float64>
>>> s.iloc_notna_last()
2
SeriesHE.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).

>>> s = sf.SeriesHE((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          2
b          8
c          19
d          34
e          54
<<U1>      <int64>
>>> s.iloc_searchsorted(18)
2
SeriesHE.insert_after(key, container)

Create a new Series by inserting a Series at the position after the label specified by key.

Parameters
  • key – Label after which the new container will be inserted.

  • container – Container to be inserted.

Returns

Series

>>> s1 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((4, 3, 12), index=('d', 'e', 'f'))
>>> s1.insert_after('b', s2)
<SeriesHE>
<Index>
a          10
b          2
d          4
e          3
f          12
c          8
<<U1>      <int64>
SeriesHE.insert_before(key, container)

Create a new Series by inserting a Series at the position before the label specified by key.

Parameters
  • key – Label before which the new container will be inserted.

  • container – Container to be inserted.

Returns

Series

>>> s1 = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s2 = sf.SeriesHE((4, 3, 12), index=('d', 'e', 'f'))
>>> s1.insert_before('b', s2)
<SeriesHE>
<Index>
a          10
d          4
e          3
f          12
b          2
c          8
<<U1>      <int64>
SeriesHE.isfalsy()

Return a same-indexed, Boolean Series indicating which values are falsy.

>>> s = sf.SeriesHE((2, '', 19, 0, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          2
b
c          19
d          0
e          None
<<U1>      <object>
>>> s.isfalsy()
<SeriesHE>
<Index>
a          False
b          True
c          False
d          True
e          True
<<U1>      <bool>
SeriesHE.isin(other)

Return a same-sized Boolean Series that shows if the same-positioned element is in the iterable passed to the function.

Returns

Series

>>> s = sf.SeriesHE((2, '', 19, 0, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s.isin((2, 19))
<SeriesHE>
<Index>
a          True
b          False
c          True
d          False
e          False
<<U1>      <bool>
SeriesHE.isna()

Return a same-indexed, Boolean Series indicating which values are NaN or None.

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.isna()
<SeriesHE>
<Index>
a          False
b          False
c          True
d          False
e          True
<<U1>      <bool>
SeriesHE.loc_max(*, skipna=True)

Return the label corresponding to the maximum value found.

Parameters

skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

Returns

tp.Hashable

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.loc_max()
a
SeriesHE.loc_min(*, skipna=True)

Return the label corresponding to the minimum value found.

Parameters

skipna – if True, NaN or None values will be ignored; if False, a found NaN will propagate.

Returns

tp.Hashable

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.loc_min()
b
SeriesHE.loc_notfalsy_first(*, fill_value=nan)

Return the label corresponding to the first non-falsy (including nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a
b
c          19
d          34
e          None
<<U1>      <object>
>>> s.loc_notfalsy_first()
c
SeriesHE.loc_notfalsy_last(*, fill_value=nan)

Return the label corresponding to the last non-falsy (including nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a
b
c          19
d          34
e          None
<<U1>      <object>
>>> s.loc_notfalsy_last()
d
SeriesHE.loc_notna_first(*, fill_value=nan)

Return the label corresponding to the first not NA (None or nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          nan
b          2.124
c          8.734
d          nan
e          nan
<<U1>      <float64>
>>> s.loc_notna_first()
b
SeriesHE.loc_notna_last(*, fill_value=- 1)

Return the label corresponding to the last not NA (None or nan) value found.

Parameters

{fill_value}

Returns

tp.Hashable

>>> s = sf.SeriesHE((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          nan
b          2.124
c          8.734
d          nan
e          nan
<<U1>      <float64>
>>> s.loc_notna_last()
c
SeriesHE.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.

>>> s = sf.SeriesHE((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          2
b          8
c          19
d          34
e          54
<<U1>      <int64>
>>> s.loc_searchsorted(18)
c
SeriesHE.max(axis=0, skipna=True)

Return the maximum along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

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

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.max()
10
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.mean()
6.666666666666667
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.median()
8.0
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.min()
2
SeriesHE.notfalsy()

Return a same-indexed, Boolean Series indicating which values are falsy.

>>> s = sf.SeriesHE((2, '', 19, 0, None), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          2
b
c          19
d          0
e          None
<<U1>      <object>
>>> s.notfalsy()
<SeriesHE>
<Index>
a          True
b          False
c          True
d          False
e          False
<<U1>      <bool>
SeriesHE.notna()

Return a same-indexed, Boolean Series indicating which values are NaN or None.

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.notna()
<SeriesHE>
<Index>
a          True
b          True
c          False
d          True
e          False
<<U1>      <bool>
SeriesHE.prod(axis=0, skipna=True, out=None)

Return the product along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

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

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.prod()
160
SeriesHE.rank_dense(*, skipna=True, ascending=True, start=0, fill_value=nan)

Rank values as compactly as possible, where ties get the same value, and ranks are contiguous (potentially non-unique) integers.

Parameters
  • skipna – If True, exclude NA values (NaN or None) from ranking, replacing those values with fill_value.

  • ascending – If True, the lowest ranks correspond to the lowest values. The default is True.

  • start – The reference value for the lowest rank. Some ranking methodologies (mean, max) may not return this value given some inputs. The default is 0; for ranks that start from 1, provide a value of 1.

  • fill_value – A value to be used to fill NA values ignored in ranking when skipna is True. The default is np.nan but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.rank_dense()
<SeriesHE>
<Index>
a          2
b          1
c          0
d          2
<<U1>      <int64>
SeriesHE.rank_max(*, skipna=True, ascending=True, start=0, fill_value=nan)

Rank values where tied values are assigned the maximum ordinal rank; ranks are potentially non-contiguous and non-unique integers.

Parameters
  • skipna – If True, exclude NA values (NaN or None) from ranking, replacing those values with fill_value.

  • ascending – If True, the lowest ranks correspond to the lowest values. The default is True.

  • start – The reference value for the lowest rank. Some ranking methodologies (mean, max) may not return this value given some inputs. The default is 0; for ranks that start from 1, provide a value of 1.

  • fill_value – A value to be used to fill NA values ignored in ranking when skipna is True. The default is np.nan but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.rank_max()
<SeriesHE>
<Index>
a          3
b          1
c          0
d          3
<<U1>      <int64>
SeriesHE.rank_mean(*, skipna=True, ascending=True, start=0, fill_value=nan)

Rank values where tied values are assigned the mean of the ordinal ranks; ranks are potentially non-contiguous and non-unique floats.

Parameters
  • skipna – If True, exclude NA values (NaN or None) from ranking, replacing those values with fill_value.

  • ascending – If True, the lowest ranks correspond to the lowest values. The default is True.

  • start – The reference value for the lowest rank. Some ranking methodologies (mean, max) may not return this value given some inputs. The default is 0; for ranks that start from 1, provide a value of 1.

  • fill_value – A value to be used to fill NA values ignored in ranking when skipna is True. The default is np.nan but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.rank_mean()
<SeriesHE>
<Index>
a          2.5
b          1.0
c          0.0
d          2.5
<<U1>      <float64>
SeriesHE.rank_min(*, skipna=True, ascending=True, start=0, fill_value=nan)

Rank values where tied values are assigned the minimum ordinal rank; ranks are potentially non-contiguous and non-unique integers.

Parameters
  • skipna – If True, exclude NA values (NaN or None) from ranking, replacing those values with fill_value.

  • ascending – If True, the lowest ranks correspond to the lowest values. The default is True.

  • start – The reference value for the lowest rank. Some ranking methodologies (mean, max) may not return this value given some inputs. The default is 0; for ranks that start from 1, provide a value of 1.

  • fill_value – A value to be used to fill NA values ignored in ranking when skipna is True. The default is np.nan but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.rank_min()
<SeriesHE>
<Index>
a          2
b          1
c          0
d          2
<<U1>      <int64>
SeriesHE.rank_ordinal(*, skipna=True, ascending=True, start=0, fill_value=nan)

Rank values distinctly, where ties get distinct values that maintain their ordering, and ranks are contiguous unique integers.

Parameters
  • skipna – If True, exclude NA values (NaN or None) from ranking, replacing those values with fill_value.

  • ascending – If True, the lowest ranks correspond to the lowest values. The default is True.

  • start – The reference value for the lowest rank. Some ranking methodologies (mean, max) may not return this value given some inputs. The default is 0; for ranks that start from 1, provide a value of 1.

  • fill_value – A value to be used to fill NA values ignored in ranking when skipna is True. The default is np.nan but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.rank_ordinal()
<SeriesHE>
<Index>
a          2
b          1
c          0
d          3
<<U1>      <int64>
SeriesHE.rehierarch(depth_map, *, index_constructors=None)

Return a new Series with new a hierarchy based on the supplied depth_map.

>>> s = sf.SeriesHE((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b')))
>>> s
<SeriesHE>
<IndexHierarchy>
1                a     3
1                b     2
2                a     8
2                b     7
<int64>          <<U1> <int64>
>>> s.rehierarch((1, 0))
<SeriesHE>
<IndexHierarchy>
a                1       3
a                2       8
b                1       2
b                2       7
<<U1>            <int64> <int64>
SeriesHE.reindex(index, *, fill_value=nan, own_index=False, check_equals=True)

Return a new Series with labels defined by the provided index. The size and ordering of the data is determined by the newly provided index, where data will continue to be aligned under labels found in both the new and the old index. Labels found only in the new index will be filled with fill_value.

Parameters
  • index – An iterable of unique, hashable values, or another Index or IndexHierarchy, to be used as the labels of the index.

  • columns – An iterable of unique, hashable values, or another Index or IndexHierarchy, to be used as the labels of the index.

  • fill_value – A value to be used to fill space created by a new index that has values not found in the previous index.

  • own_index – Flag the passed index as ownable by this static_frame.Series. Primarily used by internal clients.

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.reindex(('d', 'f', 'e', 'c'), fill_value=-1)
<SeriesHE>
<Index>
d          8
f          -1
e          -1
c          0
<<U1>      <int64>
SeriesHE.relabel(index, *, index_constructor=None)

Return a new Series with transformed labels on the index. The size and ordering of the data is never changed in a relabeling operation. The resulting index must be unique.

Parameters

index – One of the following types, used to create a new Index with the same size as the previous index. (a) A mapping (as a dictionary or Series), used to lookup and transform the labels in the previous index. Previous labels not found in the mapping will be reused. (b) A function, returning a hashable, that is applied to each label in the previous index. (c) The IndexAutoFactory type, to apply an auto-incremented integer index. (d) An index initializer, i.e., either an iterable of hashables or an Index instance.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s
<SeriesHE>
<Index>
a          10
b          2
c          8
<<U1>      <int64>
>>> s.relabel(('x', 'y', 'z'))
<SeriesHE>
<Index>
x          10
y          2
z          8
<<U1>      <int64>
>>> s.relabel(dict(a='x', b='y'))
<SeriesHE>
<Index>
x          10
y          2
c          8
<<U1>      <int64>
>>> s.relabel(lambda l: f'+{l.upper()}+')
<SeriesHE>
<Index>
+A+        10
+B+        2
+C+        8
<<U3>      <int64>
SeriesHE.relabel_flat()

Return a new Series, where an IndexHierarchy (if defined) is replaced with a flat, one-dimension index of tuples.

>>> s = sf.SeriesHE((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b')))
>>> s
<SeriesHE>
<IndexHierarchy>
1                a     3
1                b     2
2                a     8
2                b     7
<int64>          <<U1> <int64>
>>> s.relabel_flat()
<SeriesHE>
<Index>
(1, 'a')   3
(1, 'b')   2
(2, 'a')   8
(2, 'b')   7
<object>   <int64>
SeriesHE.relabel_level_add(level)

Return a new Series, adding a new root level to an existing IndexHierarchy, or creating an IndexHierarchy if one is not yet defined.

Parameters

level – A hashable value to be used as a new root level, extending or creating an IndexHierarchy

>>> s = sf.SeriesHE((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b')))
>>> s
<SeriesHE>
<IndexHierarchy>
1                a     3
1                b     2
2                a     8
2                b     7
<int64>          <<U1> <int64>
>>> s.relabel_level_add('x')
<SeriesHE>
<IndexHierarchy>
x                1       a     3
x                1       b     2
x                2       a     8
x                2       b     7
<<U1>            <int64> <<U1> <int64>
SeriesHE.relabel_level_drop(count=1)

Return a new Series, dropping one or more levels from a either the root or the leaves of an IndexHierarchy. The resulting index must be unique.

Parameters

count – A positive integer drops that many outer-most (root) levels; a negative integer drops that many inner-most (leaf)levels.

>>> s = sf.SeriesHE((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b')))
>>> s
<SeriesHE>
<IndexHierarchy>
1                a     3
1                b     2
2                a     8
2                b     7
<int64>          <<U1> <int64>
>>> s.iloc[:2].relabel_level_drop(1)
<SeriesHE>
<Index>
a          3
b          2
<<U1>      <int64>
SeriesHE.rename(name=<object object>, *, index=<object object>)

Return a new Series with an updated name attribute.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'), name='x')
>>> s
<SeriesHE: x>
<Index>
a             10
b             2
c             8
<<U1>         <int64>
>>> s.rename('y')
<SeriesHE: y>
<Index>
a             10
b             2
c             8
<<U1>         <int64>
SeriesHE.roll(shift, *, include_index=False)

Return a Series with values rotated forward and wrapped around the index (with a positive shift) or backward and wrapped around the index (with a negative shift).

Parameters
  • shift – Positive or negative integer shift.

  • include_index – Determine if the Index is shifted with the underlying data.

Returns

Series

>>> s = sf.SeriesHE((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          2
b          8
c          19
d          34
e          54
<<U1>      <int64>
>>> s.roll(2)
<SeriesHE>
<Index>
a          34
b          54
c          2
d          8
e          19
<<U1>      <int64>
SeriesHE.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) –

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.sample(2, seed=0)
<SeriesHE>
<Index>
a          10.235
c          nan
<<U1>      <float64>
SeriesHE.shift(shift, *, fill_value=nan)

Return a Series with values shifted forward on the index (with a positive shift) or backward on the index (with a negative shift).

Parameters
  • shift – Positive or negative integer shift.

  • fill_value – Value to be used to fill data missing after the shift.

Returns

Series

>>> s = sf.SeriesHE((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          2
b          8
c          19
d          34
e          54
<<U1>      <int64>
>>> s.shift(2)
<SeriesHE>
<Index>
a          nan
b          nan
c          2.0
d          8.0
e          19.0
<<U1>      <float64>
SeriesHE.sort_index(*, ascending=True, kind='mergesort', key=None)

Return a new Series ordered by the sorted Index.

Parameters
  • *

  • ascendings – Boolean, or iterable of Booleans; if True, the lowest ranks correspond to the lowest values; if an iterable, apply per column or row. The default is True.

  • 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.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.sort_index()
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.sort_index(ascending=False)
<SeriesHE>
<Index>
d          8
c          0
b          5
a          8
<<U1>      <int64>
SeriesHE.sort_values(*, ascending=True, kind='mergesort', key=None)

Return a new Series ordered by the sorted values.

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.

Returns

Series

>>> s = sf.SeriesHE((8, 5, 0, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          0
d          8
<<U1>      <int64>
>>> s.sort_values()
<SeriesHE>
<Index>
c          0
b          5
a          8
d          8
<<U1>      <int64>
>>> s.sort_values(ascending=False)
<SeriesHE>
<Index>
d          8
a          8
b          5
c          0
<<U1>      <int64>
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.std()
3.39934634239519
SeriesHE.sum(axis=0, skipna=True, out=None)

Sum values along the specified axis.

Parameters
  • axis – Axis, defaulting to axis 0.

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

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.sum()
20
SeriesHE.tail(count=5)
Return a Series consisting only of the bottom elements as specified by count.

s

Parameters

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

Returns

Series

>>> s = sf.SeriesHE((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e'))
>>> s
<SeriesHE>
<Index>
a          10.235
b          2.124
c          nan
d          8.734
e          nan
<<U1>      <float64>
>>> s.tail(2)
<SeriesHE>
<Index>
d          8.734
e          nan
<<U1>      <float64>
SeriesHE.transpose()

Transpose. For a 1D immutable container, this returns a reference to self.

Returns

Series

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.transpose()
<SeriesHE>
<Index>
a          10
b          2
c          8
<<U1>      <int64>
SeriesHE.unique()

Return a NumPy array of unique values.

Returns

numpy.ndarray

>>> s = sf.SeriesHE((8, 5, None, 8), index=('a', 'b', 'c', 'd'))
>>> s
<SeriesHE>
<Index>
a          8
b          5
c          None
d          8
<<U1>      <object>
>>> s.unique()
[8 5 None]
SeriesHE.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.

>>> s = sf.SeriesHE((10, 2, 8), index=('a', 'b', 'c'))
>>> s.var()
11.555555555555557

SeriesHE: Constructor | Exporter | Attribute | Method | Dictionary-Like | Display | Assignment | Selector | Iterator | Operator Binary | Operator Unary | Accessor Values | Accessor Datetime | Accessor String | Accessor Fill Value | Accessor Regular Expression | Accessor Hashlib