Skip to content

Commit

Permalink
Replaced DataFrame.applymap() that is now deprecated with DataFrame.m…
Browse files Browse the repository at this point in the history
…ap()

Updated code to Black formatting

Signed-off-by: S.J. Guillot <[email protected]>
  • Loading branch information
sjg2203 committed Apr 4, 2024
1 parent 3e52399 commit 9ff8636
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
19 changes: 9 additions & 10 deletions src/pingouin/correlation.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Author: Raphael Vallat <[email protected]>
import warnings

import numpy as np
import pandas as pd
import pandas_flavor as pf
from scipy.spatial.distance import pdist, squareform
from scipy.stats import pearsonr, spearmanr, kendalltau

from pingouin.bayesian import bayesfactor_pearson
from pingouin.config import options
from pingouin.power import power_corr
from pingouin.multicomp import multicomp
from pingouin.effsize import compute_esci
from pingouin.utils import remove_na, _perm_pval, _postprocess_dataframe
from pingouin.bayesian import bayesfactor_pearson

from pingouin.multicomp import multicomp
from pingouin.power import power_corr
from pingouin.utils import _perm_pval,_postprocess_dataframe,remove_na
from scipy.spatial.distance import pdist,squareform
from scipy.stats import kendalltau,pearsonr,spearmanr

__all__ = ["corr", "partial_corr", "pcorr", "rcorr", "rm_corr", "distance_corr"]

Expand Down Expand Up @@ -1113,9 +1112,9 @@ def replace_pval(x):

if stars:
# Replace p-values by stars
mat_upper = mat_upper.applymap(replace_pval)
mat_upper=mat_upper.map(replace_pval)
else:
mat_upper = mat_upper.applymap(lambda x: ffp(x, precision=decimals))
mat_upper=mat_upper.map(lambda x:ffp(x,precision=decimals))

# Replace upper triangle by p-values or n
mat.to_numpy()[tif(mat, k=1)] = mat_upper.to_numpy()[tif(mat, k=1)]
Expand Down
15 changes: 8 additions & 7 deletions src/pingouin/pairwise.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Author: Raphael Vallat <[email protected]>
# Date: April 2018
import warnings
from itertools import combinations,product

import numpy as np
import pandas as pd
import pandas_flavor as pf
from itertools import combinations, product
from pingouin.config import options
from pingouin.parametric import anova
from pingouin.multicomp import multicomp
from pingouin.effsize import compute_effsize
from pingouin.utils import _check_dataframe, _flatten_list, _postprocess_dataframe
from pingouin.multicomp import multicomp
from pingouin.parametric import anova
from pingouin.utils import _check_dataframe,_flatten_list,_postprocess_dataframe
from scipy.stats import studentized_range
import warnings

__all__ = [
"pairwise_ttests",
Expand Down Expand Up @@ -758,9 +759,9 @@ def replace_pval(x):

if stars:
# Replace p-values by stars
mat_upper = mat_upper.applymap(replace_pval)
mat_upper=mat_upper.map(replace_pval)
else:
mat_upper = mat_upper.applymap(lambda x: ffp(x, precision=decimals))
mat_upper=mat_upper.map(lambda x:ffp(x,precision=decimals))

# Replace upper triangle by p-values
mat.to_numpy()[tif(mat, k=1)] = mat_upper.to_numpy()[tif(mat, k=1)]
Expand Down

0 comments on commit 9ff8636

Please sign in to comment.