Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 do you know a code that will print all correlation values using numpty and panda?
Hi guys,

I'm new to python but am using to perform correlation analysis. Do you know of a code (im using numpty and panda) that will print all correlation values? This is my code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
data = pd.read_csv('', index_col=0)
corr = data.corr()
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111)
cax = ax.matshow(corr,cmap='coolwarm', vmin=-1, vmax=1)
ticks = np.arange(0,len(data.columns),1)
plt.savefig(r'C:\Users\Austin\Desktop\atmpshperic_correlation.jpg', dpi=700)
it then produces a diagram where after I am able to type
"corr['Southsea_urban']['Residential']" in return it gives the correlation value of the specified variable.

Does any one know of a code that will allow me to print all correlation values at once? Thankyou.
Larz60+ wrote Mar-06-2019, 12:25 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

fixed for you this time, please use BBcode tags on all future posts. Thank you.
if you execute type(corr), you see that corr is a pandas.DataFrame. Pandas is heavily relies on Numpy, underlying
numpy array of a data frame can be accessed by .values attribute, e.g. corr.values. So, correlation matrix you are probably looking for is corr.values.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to filter data using a panda.DateFrame.loc pawlo392 1 609 May-27-2019, 08:47 PM
Last Post: michalmonday
  Cross-correlation between 2 planes in a 3D array Mark3232 2 1,007 May-16-2019, 09:46 AM
Last Post: Mark3232
  Make panda dataframe output pretty carstenlp 2 372 Jan-17-2019, 10:04 AM
Last Post: carstenlp
  panda, excel - script pauses and doesn't continue running, no error message william 1 397 Nov-24-2018, 01:24 AM
Last Post: ichabod801
  Panda Dataframe Rounding Issue ab0217 5 997 Nov-06-2018, 10:15 PM
Last Post: ichabod801
  Help with correlation coefficient mattjb84 7 850 Jun-29-2018, 09:56 PM
Last Post: Larz60+
  Get max values based on unique values in another list - python Antonio 8 1,528 Jun-12-2018, 07:49 PM
Last Post: Mekire
  Pandas dataframe: sum of exponentially weighted correlation matrices per row vvvcvvcv 1 713 May-29-2018, 01:09 AM
Last Post: scidam
  How to group variables & check correlation of group variables wrt single variable SriRajesh 2 603 May-23-2018, 03:01 PM
Last Post: SriRajesh
  Mistake by correlation (x, y) Jack_Sparrow 2 649 May-10-2018, 02:23 PM
Last Post: volcano63

Forum Jump:

Users browsing this thread: 1 Guest(s)