Home > Software design >  How to print only the values of the condition?
How to print only the values of the condition?

Time:05-18

I have a pearson correlation results of a specific columns of a csv:

cleanlist = df.iloc[:, [7,8,9,10,11,12]]
pearsoncorr = cleanlist.corr(method='pearson')

I want to know how to print only the values that are >= 0.01, and eliminate those that are smaller of a pearson correlation result.

Thanks for reading!

CodePudding user response:

Not sure if I understand correctly, but if you just want to print results to the screen greater than 0.01 try the following.

for value in pearsoncorr:
    if value >= 0.01:
        print(value)

CodePudding user response:

As @weasel, said in his comment there is another way If you are certain you want to return the pandas.Series as a list you can use filter function/method

filt = lambda corr : corr >=0.01

print(list(filter(filt,pearsoncorr)))
  • Related