Python Forum

Full Version: Mistake by correlation (x, y)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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/4257...wo-columns
Maybe something like
df = abba['ENTRIESn_hourly'].corr(abba['meanprecipi'])
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.