在使用数据透视图进行绘图时,出现以下错误消息。有人可以帮我解决这个问题。
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
path = r'C:\desktop\users\abc.xlsx'
data = pd.read_excel(path)
breach_date = []
for dat in range(len(data['FinalMaturity'])):
new_date = dt.datetime.strptime(data['FinalMaturity'].iloc[dat], %d%b%y)
timestamp = int(dt.datetime.timestamp(new_date))
breach_date.append(timestamp)
cr['FinalMaturity'] = pd.DataFrame(breach_date)
res = pd.pivot_table(cr, values=['Breach'], index=['FinalMaturity'], columns = ['Tenor'], aggfunc = [np.average])
a = res.index.values
b = res.columns.values
Z = res.values
X,Y = np.meshgrid(a,b)
plt.contourf(X,Y,Z)
ValueError:设置具有序列的数组元素。