Optional pandas
integration¶
Extension methods for pandas.Series
and pandas.DataFrame
.
Pandas is an optional dependency, and can be installed using pip install lmo[pandas]
.
Examples:
Univariate summary statistics:
>>> df = pd.DataFrame({"a": [1, 2, 2, 3, 4], "b": [3, 4, 4, 4, 4]})
>>> df.l_stats()
a b
r
1 2.400000 3.8
2 0.700000 0.2
3 0.142857 -1.0
4 0.285714 1.0
>>> df.aggregate(["mean", "std", "skew", "kurt"])
a b
mean 2.400000 3.800000
std 1.140175 0.447214
skew 0.404796 -2.236068
kurt -0.177515 5.000000
Comparison of L-correlation, and Pearson correlation matrices:
>>> df = pd.DataFrame({"dogs": [0.2, 0.0, 0.5, 0.4], "cats": [0.3, 0.2, 0.0, 0.1]})
>>> df.l_corr()
dogs cats
dogs 1.0 -0.764706
cats -0.8 1.000000
>>> df.corr()
dogs cats
dogs 1.000000 -0.756889
cats -0.756889 1.000000
lmo.contrib.pandas.Series
¶
Extension methods for pandas.Series
.
This class is not meant to be used directly. These methods are curried and registered as series accessors.
l_moment(r, /, trim=0, **kwargs)
¶
See lmo.l_moment
.
Returns:
Name | Type | Description |
---|---|---|
out | float | Series[float] | A scalar, or a |
l_ratio(r, k, /, trim=0, **kwargs)
¶
See lmo.l_ratio
.
Returns:
Name | Type | Description |
---|---|---|
out | float | Series[float] | A scalar, or |
l_stats(trim=0, num=4, **kwargs)
¶
See lmo.l_stats
.
Returns:
Name | Type | Description |
---|---|---|
out | Series[float] | A |