基本上,数据包含有关operators为特定activity使用的machine的信息
df.head()我有如下数据:
machine_name activity Operator_name start_datetime end_datetime reasons_for_break duration
Yash [HMC] PILLAR SUB ASSY MOUNTING ON BASE Abhishek 2018-10-10 00:50:20 2018-10-10 11:51:23 661
IMPERIAL SPINDLE MOTOR ASSEMBLY AND MOUNTING Abijith 2018-10-10 11:44:00 2018-10-10 12:26:42 42
V.R SPINDLE MOTOR ASSEMBLY AND MOUNTING Abijith 2018-10-10 11:21:02 2018-10-10 12:26:27 65
Gnutti Carlo-2[HMC] ATC MOUNTING ON MACHINE BASE Anantha Ramu 2018-10-10 00:54:59 2018-10-10 00:55:45 0
Gnutti Carlo-2[HMC] SPINDLE MOUNTING Anantha Ramu 2018-10-10 00:57:04 2018-10-10 00:58:55 MFD mistake 1
MMF-3[HMC] APC SUB ASSY MOUNTING ON BASE Ashok 2018-10-10 09:27:41 2018-10-10 12:04:31 APC UP DOWN 56
MMF-3[HMC] IT/DDRT MOUNTING ON BASE Ashok 2018-10-10 13:45:16 2018-10-10 15:13:30 88
Gnutti Carlo-2[HMC] PILLAR SUB ASSY MOUNTING ON BASE Balamurali 2018-10-10 09:17:04 2018-10-10 12:21:25 184
Gnutti Carlo-2[HMC] PILLAR SUB ASSY MOUNTING ON BASE Balamurali 2018-10-10 12:21:25 2018-10-10 13:18:54 Tea break 57问题是所有的列都是categorical数据类型,除了start_datetime和end_datetime是datetime格式,而duration是integer数据类型。
这些数据如何plotted显示它所拥有的所有信息?
我尝试使用seaborn作为:
import seaborn as sns
sns.lmplot( x="Operator_name", y="duration", data=df, fit_reg=False, hue='machine_name', legend=True)但得到的错误如下:
Categorical is not ordered for operation min
如何绘制和显示此数据的信息??
在下面的代码中尝试:
sns.catplot(x = 'Operator_name' , y = 'duration', hue ='nick_name' , data = df)得到了与x轴重叠的图

发布于 2018-10-24 21:32:05
这是一个虚拟的DataFrame
df = pd.DataFrame({'Operator_name':["Abhishek"]*4 + ['Abijith']*5 + ['Anamtha Ramu']*3,
'Duration': np.random.randint(10, 200, size = 12)})
df.head()
Operator_name Duration
0 Abhishek 153
1 Abhishek 188
2 Abhishek 51
3 Abhishek 189
4 Abijith 188你可以使用groupby:
df1 = df.groupby('Operator_name').sum().reset_index()
df1
Operator_name Duration
0 Abhishek 299
1 Abijith 458
2 Anamtha Ramu 343df1.plot.bar(x = 'Operator_name', y='Duration')您也可以使用matplotlib:
import matplotlib.pyplot as plt
plt.bar(df['Operator_name'], df['Duration'])对于Seaborn,请尝试以下代码:
sns.barplot(x = df['Operator_name'], y = df['Duration'], hue = df['machine_name'])https://stackoverflow.com/questions/52969631
复制相似问题