-1
我有一个数据帧数组:myArr=[df1,df2,df3]
这些数据帧中的每一个都有3列,我希望在循环中绘图。遍历pandas中的数据帧数组并绘制列值
colName = ['name1','name2','name3']
df_collection = [df1,df2,df3]
traces =[]
for x in range(2):
traces.append(
go.Scatter(
x=df_collection[x],
y=df_collection[x][colName[x]],
)
)
fig = go.Figure(data=traces, layout=layout)
py.offline.iplot(fig)
我得到
TypeError: Object of type 'DataFrame' is not JSON serializable
我假设'plotly'需要json序列化的对象。试试'data.to_dict()' –