Detail: Series: Method
- Series.__array__(dtype=None)
Support the __array__ interface, returning an array of values.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.__array__() [10 2 8]
- Series.__array_ufunc__(ufunc, method, *args, **kwargs)
Support for NumPy elements or arrays on the left hand of binary operators.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> np.array((0, 1, 0)) * s <Series> <Index> a 0 b 2 c 0 <<U1> <int64>
- Series.__bool__()
Raises ValueError to prohibit ambiguous use of truthy evaluation.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> bool(s) ErrorNotTruthy('The truth value of a container is ambiguous. For a truthy indicator of non-empty status, use the `size` attribute.')
- Series.__deepcopy__(memo)[source]
>>> import copy >>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> copy.deepcopy(s) <Series> <Index> a 10 b 2 c 8 <<U1> <int64>
- Series.__len__()[source]
Length of values.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> len(s) 3
- Series.__round__(decimals=0)[source]
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:
>>> s = sf.Series((10.235, 2.124, 8.734), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10.235 b 2.124 c 8.734 <<U1> <float64> >>> round(s, 1) <Series> <Index> a 10.2 b 2.1 c 8.7 <<U1> <float64>
- Series.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.Series((False, False, True), index=('a', 'b', 'c')) >>> s <Series> <Index> a False b False c True <<U1> <bool> >>> s.all() False
- Series.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.Series((False, False, True), index=('a', 'b', 'c')) >>> s <Series> <Index> a False b False c True <<U1> <bool> >>> s.any() True
- Series.astype(dtype)[source]
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:
>>> s = sf.Series((11, 1, None), index=('a', 'b', 'c')) >>> s <Series> <Index> a 11 b 1 c None <<U1> <object> >>> s.astype(float) <Series> <Index> a 11.0 b 1.0 c nan <<U1> <float64>
- Series.clip(*, lower=None, upper=None)[source]
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:
>>> s = sf.Series((10.235, 2.124, 8.734), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10.235 b 2.124 c 8.734 <<U1> <float64> >>> s.clip(lower=2.5, upper=10.1) <Series> <Index> a 10.1 b 2.5 c 8.734 <<U1> <float64>
- Series.corr(other)[source]
Return the index-aligned correlation to the supplied
Series
.- Parameters:
other – Series to be correlated with by selection on corresponding labels.
>>> s1 = sf.Series((10.235, 2.124, 8.734), index=('a', 'b', 'c')) >>> s1 <Series> <Index> a 10.235 b 2.124 c 8.734 <<U1> <float64> >>> s2 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s2 <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s1.corr(s2) 0.9977051066985492
- Series.count(*, skipna=True, skipfalsy=False, unique=False, axis=0)[source]
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
orskipfalsy
removals.
>>> s = sf.Series((8, 5, None, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c None d 8 <<U1> <object> >>> s.count(skipna=True) 3 >>> s.count(unique=True) 2
- Series.cov(other, *, ddof=1)[source]
Return the index-aligned covariance to the supplied
Series
.- Parameters:
ddof – Delta degrees of freedom, defaults to 1.
>>> s1 = sf.Series((10.235, 2.124, 8.734), index=('a', 'b', 'c')) >>> s1 <Series> <Index> a 10.235 b 2.124 c 8.734 <<U1> <float64> >>> s2 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s2 <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s1.cov(s2) 17.924999999999997
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.cumprod() <Series> <Index> a 10 b 20 c 160 <<U1> <int64>
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.cumsum() <Series> <Index> a 10 b 12 c 20 <<U1> <int64>
- Series.drop_duplicated(*, exclude_first=False, exclude_last=False)[source]
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:
>>> s = sf.Series((8, 5, None, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c None d 8 <<U1> <object> >>> s.drop_duplicated() <Series> <Index> b 5 c None <<U1> <object>
- Series.dropfalsy()[source]
Return a new
Series
after removing values of falsy.>>> s = sf.Series(('q', 'r', '', 's'), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a q b r c d s <<U1> <<U1> >>> s.dropfalsy() <Series> <Index> a q b r d s <<U1> <<U1>
- Series.dropna()[source]
Return a new
Series
after removing values of NaN or None.>>> s = sf.Series((8, 5, None, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c None d 8 <<U1> <object> >>> s.dropna() <Series> <Index> a 8 b 5 d 8 <<U1> <object>
- Series.duplicated(*, exclude_first=False, exclude_last=False)[source]
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.Series((8, 5, None, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c None d 8 <<U1> <object> >>> s.duplicated() <Series> <Index> a True b False c False d True <<U1> <bool>
- Series.equals(other, *, compare_name=False, compare_dtype=False, compare_class=False, skipna=True)[source]
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.Series((10.235, 2.124, 8.734), index=('a', 'b', 'c')) >>> s1 <Series> <Index> a 10.235 b 2.124 c 8.734 <<U1> <float64> >>> s2 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s2 <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s1.equals(s2) False
- Series.fillfalsy(value)[source]
Return a new
Series
after replacing falsy values with the supplied value. Thevalue
can be an element orSeries
.- Parameters:
value – Value to be used to replace missing values (NaN or None).
>>> s = sf.Series(('q', 'r', '', 's'), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a q b r c d s <<U1> <<U1> >>> s.fillfalsy('missing') <Series> <Index> a q b r c missing d s <<U1> <<U7>
- Series.fillfalsy_backward(limit=0)[source]
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.Series(('', '', 'r', 's'), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a b c r d s <<U1> <<U1> >>> s.fillfalsy_backward() <Series> <Index> a r b r c r d s <<U1> <<U1>
- Series.fillfalsy_forward(limit=0)[source]
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.Series(('p', 'q', '', ''), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a p b q c d <<U1> <<U1> >>> s.fillfalsy_forward() <Series> <Index> a p b q c q d q <<U1> <<U1>
- Series.fillfalsy_leading(value)[source]
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.Series(('', '', 'r', 's'), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a b c r d s <<U1> <<U1> >>> s.fillfalsy_leading('missing') <Series> <Index> a missing b missing c r d s <<U1> <<U7>
- Series.fillfalsy_trailing(value)[source]
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.Series(('p', 'q', '', ''), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a p b q c d <<U1> <<U1> >>> s.fillfalsy_trailing('missing') <Series> <Index> a p b q c missing d missing <<U1> <<U7>
- Series.fillna(value)[source]
Return a new
Series
after replacing NA (NaN or None) with the supplied value. Thevalue
can be an element orSeries
.- Parameters:
value – Value to be used to replace missing values (NaN or None).
>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.fillna(0.0) <Series> <Index> a 10.235 b 2.124 c 0.0 d 8.734 e 0.0 <<U1> <float64>
- Series.fillna_backward(limit=0)[source]
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.Series((np.nan, np.nan, 10.235, 2.124, 8.734), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a nan b nan c 10.235 d 2.124 e 8.734 <<U1> <float64> >>> s.fillna_backward() <Series> <Index> a 10.235 b 10.235 c 10.235 d 2.124 e 8.734 <<U1> <float64>
- Series.fillna_forward(limit=0)[source]
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.Series((10.235, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c 8.734 d nan e nan <<U1> <float64> >>> s.fillna_forward() <Series> <Index> a 10.235 b 2.124 c 8.734 d 8.734 e 8.734 <<U1> <float64>
- Series.fillna_leading(value)[source]
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.Series((np.nan, np.nan, 10.235, 2.124, 8.734), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a nan b nan c 10.235 d 2.124 e 8.734 <<U1> <float64> >>> s.fillna_leading(0.0) <Series> <Index> a 0.0 b 0.0 c 10.235 d 2.124 e 8.734 <<U1> <float64>
- Series.fillna_trailing(value)[source]
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.Series((10.235, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c 8.734 d nan e nan <<U1> <float64> >>> s.fillna_trailing(0.0) <Series> <Index> a 10.235 b 2.124 c 8.734 d 0.0 e 0.0 <<U1> <float64>
- Series.head(count=5)[source]
Return a
Series
consisting only of the top elements as specified bycount
.>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.head(2) <Series> <Index> a 10.235 b 2.124 <<U1> <float64>
- Series.iloc_max(*, skipna=True)[source]
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.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.iloc_max() 0
- Series.iloc_min(*, skipna=True)[source]
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.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.iloc_min() 1
- Series.iloc_notfalsy_first(*, fill_value=-1)[source]
Return the position corresponding to the first non-falsy (including nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a b c 19 d 34 e None <<U1> <object> >>> s.iloc_notfalsy_first() 2
- Series.iloc_notfalsy_last(*, fill_value=-1)[source]
Return the position corresponding to the last non-falsy (including nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a b c 19 d 34 e None <<U1> <object> >>> s.iloc_notfalsy_last() 3
- Series.iloc_notna_first(*, fill_value=-1)[source]
Return the position corresponding to the first not NA (None or nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a nan b 2.124 c 8.734 d nan e nan <<U1> <float64> >>> s.iloc_notna_first() 1
- Series.iloc_notna_last(*, fill_value=-1)[source]
Return the position corresponding to the last not NA (None or nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a nan b 2.124 c 8.734 d nan e nan <<U1> <float64> >>> s.iloc_notna_last() 2
- Series.iloc_searchsorted(values, *, side_left=True)[source]
Given a sorted
Series
, return the iloc (integer) position(s) at which insertion invalues
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.Series((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 2 b 8 c 19 d 34 e 54 <<U1> <int64> >>> s.iloc_searchsorted(18) 2
- Series.insert_after(key, container)[source]
Create a new
Series
by inserting aSeries
at the position after the label specified bykey
.- Parameters:
key – Label after which the new container will be inserted.
container – Container to be inserted.
- Returns:
>>> s1 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s2 = sf.Series((4, 3, 12), index=('d', 'e', 'f')) >>> s1.insert_after('b', s2) <Series> <Index> a 10 b 2 d 4 e 3 f 12 c 8 <<U1> <int64>
- Series.insert_before(key, container)[source]
Create a new
Series
by inserting aSeries
at the position before the label specified bykey
.- Parameters:
key – Label before which the new container will be inserted.
container – Container to be inserted.
- Returns:
>>> s1 = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s2 = sf.Series((4, 3, 12), index=('d', 'e', 'f')) >>> s1.insert_before('b', s2) <Series> <Index> a 10 d 4 e 3 f 12 b 2 c 8 <<U1> <int64>
- Series.isfalsy()[source]
Return a same-indexed, Boolean
Series
indicating which values are falsy.>>> s = sf.Series((2, '', 19, 0, None), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 2 b c 19 d 0 e None <<U1> <object> >>> s.isfalsy() <Series> <Index> a False b True c False d True e True <<U1> <bool>
- Series.isin(other)[source]
Return a same-sized Boolean Series that shows if the same-positioned element is in the iterable passed to the function.
- Returns:
>>> s = sf.Series((2, '', 19, 0, None), index=('a', 'b', 'c', 'd', 'e')) >>> s.isin((2, 19)) <Series> <Index> a True b False c True d False e False <<U1> <bool>
- Series.isna()[source]
Return a same-indexed, Boolean
Series
indicating which values are NaN or None.>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.isna() <Series> <Index> a False b False c True d False e True <<U1> <bool>
- Series.loc_max(*, skipna=True)[source]
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:
TLabel
>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.loc_max() a
- Series.loc_min(*, skipna=True)[source]
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:
TLabel
>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.loc_min() b
- Series.loc_notfalsy_first(*, fill_value=nan)[source]
Return the label corresponding to the first non-falsy (including nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a b c 19 d 34 e None <<U1> <object> >>> s.loc_notfalsy_first() c
- Series.loc_notfalsy_last(*, fill_value=nan)[source]
Return the label corresponding to the last non-falsy (including nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series(('', '', 19, 34, None), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a b c 19 d 34 e None <<U1> <object> >>> s.loc_notfalsy_last() d
- Series.loc_notna_first(*, fill_value=nan)[source]
Return the label corresponding to the first not NA (None or nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a nan b 2.124 c 8.734 d nan e nan <<U1> <float64> >>> s.loc_notna_first() b
- Series.loc_notna_last(*, fill_value=-1)[source]
Return the label corresponding to the last not NA (None or nan) value found.
- Parameters:
{fill_value} –
- Returns:
TLabel
>>> s = sf.Series((np.nan, 2.124, 8.734, np.nan, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a nan b 2.124 c 8.734 d nan e nan <<U1> <float64> >>> s.loc_notna_last() c
- Series.loc_searchsorted(values, *, side_left=True, fill_value=nan)[source]
Given a sorted
Series
, return the loc (label) position(s) at which insertion invalues
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.Series((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 2 b 8 c 19 d 34 e 54 <<U1> <int64> >>> s.loc_searchsorted(18) c
- Series.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.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.max() 10
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.mean() 6.666666666666667
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.median() 8.0
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.min() 2
- Series.notfalsy()[source]
Return a same-indexed, Boolean
Series
indicating which values are falsy.>>> s = sf.Series((2, '', 19, 0, None), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 2 b c 19 d 0 e None <<U1> <object> >>> s.notfalsy() <Series> <Index> a True b False c True d False e False <<U1> <bool>
- Series.notna()[source]
Return a same-indexed, Boolean
Series
indicating which values are NaN or None.>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.notna() <Series> <Index> a True b True c False d True e False <<U1> <bool>
- Series.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.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.prod() 160
- Series.rank_dense(*, skipna=True, ascending=True, start=0, fill_value=nan)[source]
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 withfill_value
.ascending – If
True
, the lowest ranks correspond to the lowest values. The default isTrue
.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
isTrue
. The default isnp.nan
but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.
- Returns:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.rank_dense() <Series> <Index> a 2 b 1 c 0 d 2 <<U1> <int64>
- Series.rank_max(*, skipna=True, ascending=True, start=0, fill_value=nan)[source]
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 withfill_value
.ascending – If
True
, the lowest ranks correspond to the lowest values. The default isTrue
.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
isTrue
. The default isnp.nan
but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.
- Returns:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.rank_max() <Series> <Index> a 3 b 1 c 0 d 3 <<U1> <int64>
- Series.rank_mean(*, skipna=True, ascending=True, start=0, fill_value=nan)[source]
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 withfill_value
.ascending – If
True
, the lowest ranks correspond to the lowest values. The default isTrue
.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
isTrue
. The default isnp.nan
but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.
- Returns:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.rank_mean() <Series> <Index> a 2.5 b 1.0 c 0.0 d 2.5 <<U1> <float64>
- Series.rank_min(*, skipna=True, ascending=True, start=0, fill_value=nan)[source]
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 withfill_value
.ascending – If
True
, the lowest ranks correspond to the lowest values. The default isTrue
.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
isTrue
. The default isnp.nan
but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.
- Returns:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.rank_min() <Series> <Index> a 2 b 1 c 0 d 2 <<U1> <int64>
- Series.rank_ordinal(*, skipna=True, ascending=True, start=0, fill_value=nan)[source]
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 withfill_value
.ascending – If
True
, the lowest ranks correspond to the lowest values. The default isTrue
.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
isTrue
. The default isnp.nan
but can be set to any value to force NA values to the “bottom” or “top” of a rank as needed.
- Returns:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.rank_ordinal() <Series> <Index> a 2 b 1 c 0 d 3 <<U1> <int64>
- Series.rehierarch(depth_map, *, index_constructors=None)[source]
Return a new
Series
with new a hierarchy based on the supplieddepth_map
.>>> s = sf.Series((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b'))) >>> s <Series> <IndexHierarchy> 1 a 3 1 b 2 2 a 8 2 b 7 <int64> <<U1> <int64> >>> s.rehierarch((1, 0)) <Series> <IndexHierarchy> a 1 3 a 2 8 b 1 2 b 2 7 <<U1> <int64> <int64>
- Series.reindex(index, *, fill_value=nan, own_index=False, check_equals=True)[source]
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 withfill_value
.- Parameters:
index – An iterable of unique, hashable values, or another
Index
orIndexHierarchy
, to be used as the labels of the index.columns – An iterable of unique, hashable values, or another
Index
orIndexHierarchy
, 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.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.reindex(('d', 'f', 'e', 'c'), fill_value=-1) <Series> <Index> d 8 f -1 e -1 c 0 <<U1> <int64>
- Series.relabel(index, *, index_constructor=None)[source]
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 new index labels 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. 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) TheIndexAutoFactory
type, to apply auto-incremented integer labels. (d) AnIndex
initializer, i.e., either an iterable of hashables or anIndex
instance.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.relabel(('x', 'y', 'z')) <Series> <Index> x 10 y 2 z 8 <<U1> <int64> >>> s.relabel(dict(a='x', b='y')) <Series> <Index> x 10 y 2 c 8 <<U1> <int64> >>> s.relabel(lambda l: f'+{l.upper()}+') <Series> <Index> +A+ 10 +B+ 2 +C+ 8 <<U3> <int64>
- Series.relabel_flat()[source]
Return a new
Series
, where anIndexHierarchy
(if defined) is replaced with a flat, one-dimension index of tuples.>>> s = sf.Series((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b'))) >>> s <Series> <IndexHierarchy> 1 a 3 1 b 2 2 a 8 2 b 7 <int64> <<U1> <int64> >>> s.relabel_flat() <Series> <Index> (1, 'a') 3 (1, 'b') 2 (2, 'a') 8 (2, 'b') 7 <object> <int64>
- Series.relabel_level_add(level, *, index_constructor=None)[source]
Return a new
Series
, adding a new root level to an existingIndexHierarchy
, or creating anIndexHierarchy
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.Series((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b'))) >>> s <Series> <IndexHierarchy> 1 a 3 1 b 2 2 a 8 2 b 7 <int64> <<U1> <int64> >>> s.relabel_level_add('x') <Series> <IndexHierarchy> x 1 a 3 x 1 b 2 x 2 a 8 x 2 b 7 <<U1> <int64> <<U1> <int64>
- Series.relabel_level_drop(count=1)[source]
Return a new
Series
, dropping one or more levels from a either the root or the leaves of anIndexHierarchy
. 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.Series((3, 2, 8, 7), index=sf.IndexHierarchy.from_product((1, 2), ('a', 'b'))) >>> s <Series> <IndexHierarchy> 1 a 3 1 b 2 2 a 8 2 b 7 <int64> <<U1> <int64> >>> s.iloc[:2].relabel_level_drop(1) <Series> <Index> a 3 b 2 <<U1> <int64>
- Series.rename(name=<object object>, *, index=<object object>)[source]
Return a new Series with an updated name attribute.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c'), name='x') >>> s <Series: x> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.rename('y') <Series: y> <Index> a 10 b 2 c 8 <<U1> <int64>
- Series.roll(shift, *, include_index=False)[source]
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:
>>> s = sf.Series((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 2 b 8 c 19 d 34 e 54 <<U1> <int64> >>> s.roll(2) <Series> <Index> a 34 b 54 c 2 d 8 e 19 <<U1> <int64>
- Series.sample(count=1, *, seed=None)[source]
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.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.sample(2, seed=0) <Series> <Index> a 10.235 c nan <<U1> <float64>
- Series.shift(shift, *, fill_value=nan)[source]
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:
>>> s = sf.Series((2, 8, 19, 34, 54), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 2 b 8 c 19 d 34 e 54 <<U1> <int64> >>> s.shift(2) <Series> <Index> a nan b nan c 2.0 d 8.0 e 19.0 <<U1> <float64>
- Series.sort_index(*, ascending=True, kind='mergesort', key=None)[source]
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 isTrue
.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:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.sort_index() <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.sort_index(ascending=False) <Series> <Index> d 8 c 0 b 5 a 8 <<U1> <int64>
- Series.sort_values(*, ascending=True, kind='mergesort', key=None)[source]
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:
>>> s = sf.Series((8, 5, 0, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c 0 d 8 <<U1> <int64> >>> s.sort_values() <Series> <Index> c 0 b 5 a 8 d 8 <<U1> <int64> >>> s.sort_values(ascending=False) <Series> <Index> d 8 a 8 b 5 c 0 <<U1> <int64>
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.std() 3.39934634239519
- Series.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.
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.sum() 20
- Series.tail(count=5)[source]
- Return a
Series
consisting only of the bottom elements as specified bycount
. s
>>> s = sf.Series((10.235, 2.124, np.nan, 8.734, np.nan), index=('a', 'b', 'c', 'd', 'e')) >>> s <Series> <Index> a 10.235 b 2.124 c nan d 8.734 e nan <<U1> <float64> >>> s.tail(2) <Series> <Index> d 8.734 e nan <<U1> <float64>
- Return a
- Series.transpose()[source]
Transpose. For a 1D immutable container, this returns a reference to self.
- Returns:
>>> s = sf.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.transpose() <Series> <Index> a 10 b 2 c 8 <<U1> <int64>
- Series.unique()[source]
Return a NumPy array of unique values.
- Returns:
numpy.ndarray
>>> s = sf.Series((8, 5, None, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c None d 8 <<U1> <object> >>> s.unique() [8 5 None]
- Series.unique_enumerated(*, retain_order=False, func=None)[source]
Given a collection of values, return two NumPy arrays: the first provides index positions for lookup of observed values; the second provides those observed, unique, values. Sometimes called “factorize”.
- Parameters:
retain_order – Boolean. If True, observed order is retained. If False, order may be sorted or observed, depending on the dtype and values. Retaining order may decrease performance.
func – A callable that takes an element and returns a Boolean if that element should be treated as missing, excluded from the unique value collection, and given a -1 indexer position. The NumPy function np.isnan or the StaticFrame sf.isna_element are examples of suitable functions.
>>> s = sf.Series((8, 5, None, 8), index=('a', 'b', 'c', 'd')) >>> s <Series> <Index> a 8 b 5 c None d 8 <<U1> <object> >>> s.unique_enumerated() (array([0, 1, 2, 0]), array([8, 5, None], dtype=object))
- Series.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.Series((10, 2, 8), index=('a', 'b', 'c')) >>> s <Series> <Index> a 10 b 2 c 8 <<U1> <int64> >>> s.var() 11.555555555555557
Series: 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 | Accessor Type Clinic | Accessor Mapping