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 pandas warning #323

Merged
merged 5 commits into from
Dec 15, 2022
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
8 changes: 4 additions & 4 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, 3.10.8]

runs-on: ${{ matrix.platform }}

Expand All @@ -39,21 +39,21 @@ jobs:
pytest --cov --cov-report=xml --cov-config=setup.cfg --verbose

- name: Build docs
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.8 }}
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.9 }}
run: |
pip install --upgrade sphinx sphinx_bootstrap_theme numpydoc sphinx-copybutton sphinx-panels
make -C docs clean
make -C docs html

- name: Upload doc build artifacts
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.8 }}
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.9 }}
uses: actions/upload-artifact@v1
with:
name: docs-artifact
path: docs/build/html

- name: Upload coverage report
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.8 }}
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.9 }}
uses: codecov/codecov-action@v1
with:
token: c6ed6ca6-a040-4f23-9ebf-8c474c998097
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ In addition, some functions require :
* `Scikit-learn <https://scikit-learn.org/>`_
* `Mpmath <http://mpmath.org/>`_

Pingouin is a Python 3 package and is currently tested for Python 3.7-3.9. It does not support Python 2.
Pingouin is a Python 3 package and is currently tested for Python 3.7-3.10. It does not support Python 2.

User installation
-----------------
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ the :code:`ttest` function of Pingouin returns the T-value, the p-value, the deg
Installation
============

Pingouin is a Python 3 package and is currently tested for Python 3.7-3.9. It does not support Python 2.
Pingouin is a Python 3 package and is currently tested for Python 3.7-3.10. It does not support Python 2.

The main dependencies of Pingouin are :

Expand Down
6 changes: 5 additions & 1 deletion pingouin/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,11 @@ def _check_multilevel_rm(data, func="epsilon"):
# We end up with a one-way design. It is similar to applying
# a paired T-test to gain scores instead of using repeated measures
# on two time points. Here we have computed the gain scores.
data = data.groupby(level=1, axis=1, observed=True).diff(axis=1).dropna(axis=1)
data = (
data.groupby(level=1, axis=1, observed=True, group_keys=False)
.diff(axis=1)
.dropna(axis=1)
)
data = data.droplevel(level=0, axis=1)
else:
# Both factors have more than 2 levels -- differ from R / JASP
Expand Down
12 changes: 6 additions & 6 deletions pingouin/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def rm_anova(
# Groupby
# I think that observed=True is actually not needed here since we have already used
# `observed=True` in pivot_table.
grp_with = data.groupby(within, observed=True)[dv]
grp_with = data.groupby(within, observed=True, group_keys=False)[dv]
rm = list(data[within].unique())
n_rm = len(rm)
n_obs = int(grp_with.count().max())
Expand Down Expand Up @@ -989,12 +989,12 @@ def anova(data=None, dv=None, between=None, ss_type=2, detailed=False, effsize="
N = data[dv].size

# Calculate sums of squares
grp = data.groupby(between, observed=True)[dv]
grp = data.groupby(between, observed=True, group_keys=False)[dv]
# Between effect
ssbetween = ((grp.mean() - data[dv].mean()) ** 2 * grp.count()).sum()
# Within effect (= error between)
# = (grp.var(ddof=0) * grp.count()).sum()
sserror = grp.apply(lambda x: (x - x.mean()) ** 2).sum()
sserror = grp.transform(lambda x: (x - x.mean()) ** 2).sum()
# In 1-way ANOVA, sstotal = ssbetween + sserror
# sstotal = ssbetween + sserror

Expand Down Expand Up @@ -1062,7 +1062,7 @@ def anova2(data=None, dv=None, between=None, ss_type=2, effsize="np2"):

# Reset index (avoid duplicate axis error)
data = data.reset_index(drop=True)
grp_both = data.groupby(between, observed=True)[dv]
grp_both = data.groupby(between, observed=True, group_keys=False)[dv]

if grp_both.count().nunique() == 1:
# BALANCED DESIGN
Expand Down Expand Up @@ -1338,7 +1338,7 @@ def welch_anova(data=None, dv=None, between=None):
ddof1 = r - 1

# Compute weights and ajusted means
grp = data.groupby(between, observed=True)[dv]
grp = data.groupby(between, observed=True, group_keys=False)[dv]
weights = grp.count() / grp.var()
adj_grandmean = (weights * grp.mean()).sum() / weights.sum()

Expand Down Expand Up @@ -1512,7 +1512,7 @@ def mixed_anova(
ss_betw = aov_betw.at[0, "SS"]
ss_with = aov_with.at[0, "SS"]
# Extract residuals and interactions
grp = data.groupby([between, within], observed=True)[dv]
grp = data.groupby([between, within], observed=True, group_keys=False)[dv]
# ssresall = residuals within + residuals between
ss_resall = grp.apply(lambda x: (x - x.mean()) ** 2).sum()
# Interaction
Expand Down
1 change: 0 additions & 1 deletion pingouin/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ def plot_shift(

.. plot::

>>> import numpy as np
>>> import pingouin as pg
>>> import matplotlib.pyplot as plt
>>> data = pg.read_dataset("pairwise_corr")
Expand Down
2 changes: 1 addition & 1 deletion pingouin/tests/test_parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def test_mixed_anova(self):

# With overlapping subject IDs in the between-subject groups
df_overlap = df.copy()
df_overlap["Subject"] = df_overlap.groupby(["Group"])["Subject"].apply(
df_overlap["Subject"] = df_overlap.groupby(["Group"], group_keys=False)["Subject"].apply(
lambda x: x - x.min()
)
with pytest.raises(ValueError):
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ test=pytest
addopts =
--showlocals
--durations=10
--maxfail=2
--cov
# --doctest-modules --doctest-continue-on-failure | do not work with travis
doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
markers =
slow: mark a test as slow.
filterwarnings =
ignore::UserWarning
ignore::RuntimeWarning
ignore::FutureWarning

[flake8]
# W605 : bug when math equation in numpydoc
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def read(fname):
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Mathematics",
"Operating System :: POSIX",
"Operating System :: Unix",
Expand Down