dtoolkit.accessor.series.equal#
- dtoolkit.accessor.series.equal(s: Series, /, other, align: bool = True, **kwargs) Series[source]#
Return a boolean Series containing the result of comparing with
other.A sugar syntax for
np.equal(s, other, **kwargs).- Parameters:
- otherscalar or 1d array-like
The value(s) to compare with the Series.
scalar : compare each element with the scalar value.
1d array-like : compare each element with the corresponding value.
- alignbool, default True
If True, align
sandotherbefore comparing. Only works whileotheris a Series.- **kwargs
Additional keyword arguments are passed to
numpy.equal().
- Returns:
- Series(bool)
- Raises:
- ValueError
If the lengths of
sandotherare not equal.
- Warns:
- UserWarning
If
alignis True andotheris a Series, but its indexes are not equal tos.
See also
pandas.Series.eqCompare two Series.
numpy.equalReturn (x1 == x2) element-wise.
dtoolkit.accessor.dataframe.equalDataFrame version of
.equal.
Examples
>>> import dtoolkit >>> import pandas as pd >>> s = pd.Series([1, 2, 3]) >>> s 0 1 1 2 2 3 dtype: int64
Like
Series.eqmethod to compare scalar or array-like via==,Series.equalcould also do that.Compare with scalar.
>>> s == 2 0 False 1 True 2 False dtype: bool >>> s.equal(2) 0 False 1 True 2 False dtype: bool
Compare with array-like.
>>> s.equal(pd.Series([3, 2, 1])) 0 False 1 True 2 False dtype: bool >>> s.equal(pd.Series([3, 2, 1])) 0 False 1 True 2 False dtype: bool
s.equalcan also compare with array-like based on index.>>> s == pd.Series([3, 2, 1], index=[2, 1, 0]) ValueError: Can only compare identically-labeled Series objects >>> s.equal(pd.Series([3, 2, 1], index=[2, 1, 0])) 0 True 1 True 2 True dtype: bool >>> s.equal(pd.Series([3, 2, 1], index=[2, 1, 0]), align=False) 0 False 1 True 2 False dtype: bool