【发布时间】:2019-01-03 03:22:27
【问题描述】:
我有如下数据:
Machine_id 循环空闲
81091001 41000000000 19000000000
81091001 40000000000 19000000000
81091001 41000000000 19000000000
81091001 41000000000 20000000000
81091001 41000000000 19000000000
绘制饼图的代码:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(palette='Paired')
df = pd.read_csv('sample1.csv')
df = df.set_index('Machine_id')
for ind in df.index:
fig, ax = plt.subplots(1,1)
fig.set_size_inches(5,5)
df.iloc[ind].plot(kind='pie', ax=ax, autopct='%1.1f%%')
ax.set_ylabel('')
ax.set_xlabel('')
我在这里遇到错误,例如:
IndexError: single positional indexer is out-of-bounds
那么如何为Cycling v/s Idle in pandas each Machine_id 形成饼图呢?
【问题讨论】: