python 做热图的时候,总是遇到Error

各位python大神,走过路过不要错过!

Error:cannot copy sequence with size 11 to array axis with dimension 15

import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt


# Read the pharma sector data
file = r'C:/file/a.xlsx'
data = pd.read_excel(file)
df = pd.Series([data],dtype='float')

print(df)

ax = sns.heatmap(
    df,
    vmin=-1, vmax=1, center=0,
    cmap=sns.diverging_palette(220, 20, n=256),
    standard_scale =0

)

print("OK!")

plt.show()

输出结果如下:我的excel表确实是11*15

ValueError: cannot copy sequence with size 11 to array axis with dimension 15

不知道为什么如果表的数据是11*11或者15*15这样正方矩阵,是不出错误的。但是,如果不是正方,就会error。作为一个python小白,百思不得其解!

各位大神,求!跪求!

data = pd.read_excel(file)
这里调试输出下
print(data.shape)
看下是不是15*15

如果不是,就是你的excel文件的问题。

df = pd.Series([data],dtype='float') 你这行代码是想干什么? 直接把data传给sns.heatmap 不就可以了吗