Python Forum
Mistake by correlation (x, y)
Thread Rating:
  • 3 Vote(s) - 3.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mistake by correlation (x, y)
#1
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
Reply
#2
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'])
Reply
#3
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.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Correlation Coefficents with different Time Ranges giaco__mar 0 833 Sep-28-2022, 02:03 PM
Last Post: giaco__mar
  Cross-correlation between 2 planes in a 3D array Mark3232 2 4,554 May-16-2019, 09:46 AM
Last Post: Mark3232
  do you know a code that will print all correlation values using numpty and panda? crispybluewaffle88 1 2,419 Mar-06-2019, 12:45 PM
Last Post: scidam
  Help with correlation coefficient mattjb84 7 4,856 Jun-29-2018, 09:56 PM
Last Post: Larz60+
  Pandas dataframe: sum of exponentially weighted correlation matrices per row vvvcvvcv 1 3,206 May-29-2018, 01:09 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020