Python Forum
Mistake by correlation (x, y) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Mistake by correlation (x, y) (/thread-10045.html)



Mistake by correlation (x, y) - Jack_Sparrow - May-10-2018

Hi there,

I have a problem with calculation of correlation.
I have a simple table:
meanwspdi weather_lat weather_lon
0 7.860000 40.700348 -73.887177
1 7.860000 40.700348 -73.887177
2 7.860000 40.700348 -73.887177
3 7.860000 40.700348 -73.887177
4 7.860000 40.700348 -73.887177
5 8.250000 40.700348 -73.887177

(There are much more columns than this example shows)

I want to calculate the correlation between two columns ['ENTRIESn_hourly'], ['meanprecipi']
This is my code:

import pandas as pd
abba = pd.read_csv('nyc.csv')

df = abba.correlation(['ENTRIESn_hourly'], ['meanprecipi'])

But I get an error:
AttributeError: 'DataFrame' object has no attribute 'correlation'

What is my mistake?

Thank you!
J


RE: Mistake by correlation (x, y) - mlieqo - May-10-2018

Isn't it just supposed to be:
df = abba.corr(['ENTRIESn_hourly'], ['meanprecipi'])
instead of your
df = abba.correlation(['ENTRIESn_hourly'], ['meanprecipi'])
But I don't think that's correct usage of corr either, you can see example here: https://stackoverflow.com/questions/42579908/use-corr-to-get-the-correlation-between-two-columns
Maybe something like
df = abba['ENTRIESn_hourly'].corr(abba['meanprecipi'])



RE: Mistake by correlation (x, y) - volcano63 - May-10-2018

I would say - it's RTM time. You cannot advance unless you learn - and asking forum for help for every single problem is not the way.