pg.pairwise_corr error: x and y must be 1D array

147 Views Asked by At

trying with the pg.pairwise_corr method I get the following error:

pg.pairwise_corr(df)

/usr/local/lib/python3.7/dist-packages/pingouin/correlation.py in corr(x, y, tail, method, **kwargs)
    507     x = np.asarray(x)
    508     y = np.asarray(y)
--> 509     assert x.ndim == y.ndim == 1, 'x and y must be 1D array.'
    510     assert x.size == y.size, 'x and y must have the same length.'
    511 

AssertionError: x and y must be 1D array.

I tryed around with the function, selecting only one column like this

pg.pairwise_corr(df, columns='col')

and get the same error.

In fact, all columns of my dataframe have the same lenght. (And it works perfectly fine for another dataframe). However I used the pd.concat method to concat some files, but this should not matter when the object is a data.frame in the end or?

Thanks for advises!!

1

There are 1 best solutions below

0
On

meanwhile I solved my problem.

after

df = pd.concat([df_part1, df_part2], axis=1) 

I saved the df as .csv file. Then I again read in the df using

df = pd.read_csv('path/to/file', index=false)

Like this, the function

pg.pairwise_corr(df)

worked properly.