Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Pandas integration #57

Merged
merged 22 commits into from
Oct 30, 2023
Merged

Optional Pandas integration #57

merged 22 commits into from
Oct 30, 2023

Conversation

jorenham
Copy link
Owner

Most lmo.l_* functions are now available as pandas.Series and pandas.DataFrame (accessor) methods.

Whereas the lmo.l_* functions return numpy arrays (or scalars), the new methods return properly-indexed Series or DataFrame instances.
Also, the univariate DataFrame methods accept pandas-style axis parameters, e.g. axis='index or axis='columns , as alias for axis=0 or axis=1, respectively.

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': [.2, .0, .5, .4], 'cats': [.3, .2, .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

@jorenham jorenham merged commit 4435832 into master Oct 30, 2023
4 checks passed
@jorenham jorenham deleted the contrib-pandas branch October 30, 2023 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant