Skip to content

partial_corr documentation / assertion wrong #387

@mkeds

Description

@mkeds

The following minimum code example straight from documentation

https://pingouin-stats.org/build/html/generated/pingouin.partial_corr.html#pingouin.partial_corr
Example 1

import pingouin as pg
df = pg.read_dataset('partial_corr')
pg.partial_corr(data=df, x='x', y='y', covar='cv1').round(3)
n r CI95% p-val
pearson 30 0.568 [0.25, 0.77] 0.001

returns:
AssertionError: columns are not in dataframe.

on line 843 from correlation.py:
assert all([c in data for c in col]), "columns are not in dataframe."

which kind of makes sense, because just before in line 842 we have:
col = _flatten_list([x, y, covar, x_covar, y_covar])

and since we don't supply x_covar y_covar when calling the function in the example, they default to None in function header, and None in not in the DataFrame by default:

In[664]: None in df Out[664]: False

Is this expected behaviour or something wrong with my Pandas? I'm using pandas=2.1.2,

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions