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

Fix doctests #390

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pingouin/contingency.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ def chi2_independence(data, x, y, correction=True):
>>> import pingouin as pg
>>> data = pg.read_dataset('chi2_independence')
>>> data['sex'].value_counts(ascending=True)
sex
0 96
1 207
Name: sex, dtype: int64
Name: count, dtype: int64

If gender is not a good predictor for heart disease, we should expect the
same 96:207 ratio across the target classes.
Expand Down
34 changes: 16 additions & 18 deletions pingouin/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,17 +680,16 @@ def epsilon(data, dv=None, within=None, subject=None, correction="gg"):
levels:

>>> # Pivot from long-format to wide-format
>>> piv = data.pivot_table(index='Subject', columns=['Time', 'Metric'],
... values='Performance')
>>> piv = data.pivot(index='Subject', columns=['Time', 'Metric'], values='Performance')
>>> piv.head()
Time Post Pre
Metric Action Client Product Action Client Product
Time Pre Post
Metric Product Client Action Product Client Action
Subject
1 34 30 18 17 12 13
2 30 18 6 18 19 12
3 32 31 21 24 19 17
4 40 39 18 25 25 12
5 27 28 18 19 27 19
1 13 12 17 18 30 34
2 12 19 18 6 18 30
3 17 19 24 21 31 32
4 12 25 25 18 39 40
5 19 27 19 18 28 27

>>> round(pg.epsilon(piv), 3)
0.727
Expand Down Expand Up @@ -934,17 +933,16 @@ def sphericity(data, dv=None, within=None, subject=None, method="mauchly", alpha
levels:

>>> # Pivot from long-format to wide-format
>>> piv = data.pivot_table(index='Subject', columns=['Time', 'Metric'],
... values='Performance')
>>> piv = data.pivot(index='Subject', columns=['Time', 'Metric'], values='Performance')
>>> piv.head()
Time Post Pre
Metric Action Client Product Action Client Product
Time Pre Post
Metric Product Client Action Product Client Action
Subject
1 34 30 18 17 12 13
2 30 18 6 18 19 12
3 32 31 21 24 19 17
4 40 39 18 25 25 12
5 27 28 18 19 27 19
1 13 12 17 18 30 34
2 12 19 18 6 18 30
3 17 19 24 21 31 32
4 12 25 25 18 39 40
5 19 27 19 18 28 27

>>> spher, _, chisq, dof, pval = pg.sphericity(piv)
>>> print(spher, round(chisq, 3), dof, round(pval, 3))
Expand Down
Loading