# My corr() function in Python keeps resulting in an “ValueError: The truth value of a Series is ambiguous…” [closed]

I am a very inexperienced programmer, this is my first question on the Data Science StackExchange, I sorry if it is formatted poorly or comes across as basic. For some strange reason, in Python, whenever I try to run a correlation function on the population density & total cases per million columns of my COVID-19 DataFrame (which I imported/read into Spyder as a csv), I keep getting the same long error message, namely, "ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()." regardless of whether I use the correlation function from Pandas or Numpy. My first thought was that this error was caused by the presence of null values in those columns, so I used df.dropna(), then ran the correlation function again but I got the same "ValueError", so I have no idea what is going on here, I was able to run a correlation on those same columns just fine in RStudio which I am equally unskilled and inexperienced with.

• Try to add method ='pearson' in your parenthesis, this way : df.corr(df[...], df[...], method ='pearson'). Not sure if it will work but there seems to be an error on which method you use / on the fact that you don't precise the method for the corr function – BeamsAdept Oct 6 '20 at 9:14
• @BeamsAdept thank you for the suggestion, I went ahead and tried running it with the extra pearson argument and it did get rid of the ValueError which is great! Unfortunately, now it is saying there is a TypeError, this is the exact output now: In [9]: df.corr(df['population_density'], df['total_cases_per_million'], ...: method = 'pearson') Traceback (most recent call last): File "<ipython-input-9-236734901706>", line 2, in <module> method = 'pearson') TypeError: corr() got multiple values for argument 'method' – Marlen Oct 6 '20 at 9:42

subset_df = df[['col1', 'col2']]