do you know a code that will print all correlation values using numpty and panda? - 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: do you know a code that will print all correlation values using numpty and panda? (/thread-16593.html) |
do you know a code that will print all correlation values using numpty and panda? - crispybluewaffle88 - Mar-06-2019 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('https://www.dropbox.com/s/cneg6eh0hznp8zo/atmospheric_temperature.csv?raw=1', 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) fig.colorbar(cax) ticks = np.arange(0,len(data.columns),1) ax.set_xticks(ticks) plt.xticks(rotation=90) ax.set_yticks(ticks) ax.set_xticklabels(data.columns) ax.set_yticklabels(data.columns) plt.savefig(r'C:\Users\Austin\Desktop\atmpshperic_correlation.jpg', dpi=700) plt.show()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. RE: do you know a code that will print all correlation values using numpty and panda? - scidam - Mar-06-2019 if you execute type(corr) , you see that corr is a pandas.DataFrame. Pandas is heavily relies on Numpy, underlyingnumpy 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 .
|