Привет. Я пытаюсь рассчитать среднюю продолжительность вызовов для разных категорий вызовов. Есть около 25 категорий
Текущий сюжет имеет все 25 категорий и не очень понятен
Как мне разбить это на 5 участков по 5 категорий в каждом.
Ниже приведен код, который я использовал для создания сюжета
#Calculate the mean and standard deviation for duration based on call classes
mean_total_duration = rawdata[['cclass', 'Duration']].groupby('cclass').agg([np.mean, np.std])
mean_total_duration.columns = mean_total_duration.columns.droplevel()
# Define a function for a bar plot
def barplot(x_data, y_data, error_data, x_label, y_label, title):
_, ax = plt.subplots()
# Draw bars, position them in the center of the tick mark on the x-axis
ax.bar(x_data, y_data, color = '#539caf', align = 'center')
# Draw error bars to show standard deviation, set ls to 'none'
# to remove line between points
ax.errorbar(x_data, y_data, yerr = error_data, color = '#297083', ls = 'none', lw = 2, capthick = 2)
ax.set_ylabel(y_label)
ax.set_xlabel(x_label)
ax.set_title(title)
# Call the function to create plot
print(mean_total_duration.index.values)
print(mean_total_duration['mean'])
barplot(x_data = mean_total_duration.index.values
, y_data = mean_total_duration['mean']
, error_data = mean_total_duration['std']
, x_label = 'call classes '
, y_label = 'Call Duration'
, title = 'Call Duration for call classes')