Skip to content

Instantly share code, notes, and snippets.

@jacepark12
Created August 31, 2018 02:19
Show Gist options
  • Select an option

  • Save jacepark12/731ebb44bcdf0e654d6553afa4f77cba to your computer and use it in GitHub Desktop.

Select an option

Save jacepark12/731ebb44bcdf0e654d6553afa4f77cba to your computer and use it in GitHub Desktop.
from matplotlib import pyplot as plt
import numpy as np
randn = np.random.randn
import pandas as pd
from scipy.stats.stats import pearsonr
df = pd.read_excel('data_2.xlsx')
print(df)
c = pd.Series(df.columns.values, name='x').tolist()
remove_list = ['Year', 'Company', '설립연도']
for x in remove_list:
c.remove(x)
print(c)
#idx = pd.Index(arange(1,11))
df = pd.DataFrame(randn(24, 24), index=c, columns=c)
#vals = np.around(df.values,2)
#normal = plt.normalize(vals.min()-1, vals.max()+1)
fig = plt.figure(figsize=(15,8))
ax = fig.add_subplot(111, frameon=True, xticks=[], yticks=[])
cell_text = []
for i in c:
_t = []
for j in c:
r, p_v = pearsonr(df[i], df[j])
_t.append(r)
cell_text.append(_t)
img = plt.imshow(cell_text, cmap="hot")
plt.colorbar()
tb=plt.table(cellText=cell_text, rowLabels=df.index, colLabels=df.columns,
loc='center',
cellColours=plt.cm.hot(cell_text))
ax.add_table(tb)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment