chicken_turtle_util.series¶
Utilities for working with pandas.Series. Contains only invert, swaps series’ index with its values
assert_equals |
Assert 2 series are equal |
equals |
Get whether 2 series are equal |
invert |
Swap index with values of series |
split |
Split values |
-
chicken_turtle_util.series.
assert_equals
(series1, series2, ignore_order=False, ignore_index=False, all_close=False)[source]¶ Assert 2 series are equal
Like
assert equals(series1, series2, ...)
, but with better hints at where the series differ. Seechicken_turtle_util.series.equals()
for detailed parameter doc.Parameters: series1, series2 : pd.Series
ignore_order : bool
ignore_index : bool
all_close : bool
-
chicken_turtle_util.series.
equals
(series1, series2, ignore_order=False, ignore_index=False, all_close=False, _return_reason=False)[source]¶ Get whether 2 series are equal
NaN
s are considered equal (which is consistent with pandas.Series.equals).None
is considered equal toNaN
.Parameters: series1, series2 : pd.Series
Series to compare
ignore_order : bool
Ignore order of values (and index)
ignore_index : bool
Ignore index values and name.
all_close : bool
If False, values must match exactly, if True, floats are compared as if compared with np.isclose.
_return_reason : bool
Internal. If True, equals returns a tuple containing the reason, else equals only returns a bool indicating equality (or equivalence rather).
Returns: equal : bool
Whether they’re equal (after ignoring according to the parameters)
reason : str or None
If equal,
None
, otherwise short explanation of why the data frames aren’t equal. Omitted if not _return_reason.See also
data_frame.equals
- Get whether 2 data frames are equal
Notes
All values (including those of indices) must be copyable and __eq__ must be such that a copy must equal its original. A value must equal itself unless it’s np.nan. Values needn’t be orderable or hashable (however pandas requires index values to be orderable and hashable). By consequence, this is not an efficient function, but it is flexible.
-
chicken_turtle_util.series.
invert
(series)[source]¶ Swap index with values of series
Parameters: series
Series to swap on, must have a name
Returns: pandas.Series
Series after swap
See also
pandas.Series.map
- Joins series
a -> b
andb -> c
intoa -> c
.
-
chicken_turtle_util.series.
split
(series)[source]¶ Split values
The index is dropped, but this may change in the future.
Parameters: series : pd.Series
Series with numpy array-like values.
Returns: pd.Series
Series with values split across rows.
Examples
>>> series = pd.Series([[1,2],[1,2],[3,4,5]]) >>> series 0 [1, 2] 1 [1, 2] 2 [3, 4, 5] dtype: object >>> split(series) 0 1 1 2 2 1 3 2 4 3 5 4 6 5 dtype: object