Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/pingouin/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ def partial_corr(
"pearson",
"spearman",
], 'only "pearson" and "spearman" are supported for partial correlation.'
assert isinstance(data, pd.DataFrame), "data must be a pandas DataFrame."
assert hasattr(data, "__dataframe__"), "Data must be compatible with DataFrame"
assert data.shape[0] > 2, "Data must have at least 3 samples."
if covar is not None and (x_covar is not None or y_covar is not None):
raise ValueError("Cannot specify both covar and {x,y}_covar.")
Expand Down Expand Up @@ -1189,7 +1189,7 @@ def rm_corr(data=None, x=None, y=None, subject=None):
from pingouin import ancova, power_corr

# Safety checks
assert isinstance(data, pd.DataFrame), "Data must be a DataFrame"
assert hasattr(data, "__dataframe__"), "Data must be compatible with DataFrame"
assert x in data.columns, "The %s column is not in data." % x
assert y in data.columns, "The %s column is not in data." % y
assert data[x].dtype.kind in "bfiu", "%s must be numeric." % x
Expand Down
9 changes: 6 additions & 3 deletions src/pingouin/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,16 @@ def normality(data, dv=None, group=None, method="shapiro", alpha=0.05):
Pre 0.304021 0.858979 True
Post 1.265656 0.531088 True
"""
assert isinstance(data, (pd.DataFrame, pd.Series, list, np.ndarray))
assert isinstance(data, (pd.DataFrame, pd.Series, list, np.ndarray)) or hasattr(
data, "__dataframe__"
)
assert method in ["shapiro", "normaltest", "jarque_bera"]
if isinstance(data, pd.Series):
data = data.to_frame()
col_names = ["W", "pval"]
func = getattr(scipy.stats, method)
if isinstance(data, (list, np.ndarray)):
# Check if the data is 1D array-like
if isinstance(data, (list, np.ndarray)) or (hasattr(data, "__array__") and data.ndim == 1):
data = np.asarray(data)
assert data.ndim == 1, "Data must be 1D."
assert data.size > 3, "Data must have more than 3 samples."
Expand All @@ -222,7 +225,7 @@ def normality(data, dv=None, group=None, method="shapiro", alpha=0.05):
stats.columns = col_names
stats["normal"] = np.where(stats["pval"] > alpha, True, False)
else:
# Data is a Pandas DataFrame
# Any other kind of data is assumed to be DataFrame-like
if dv is None and group is None:
# Wide-format
# Get numeric data only
Expand Down
Loading