Loading Data
Initial Questions
Analyze distribution of categories in data using Pyplot
df = pd.read_csv('instruments.csv')
df.set_index('fname', inplace=True)
for fname in df.index:
rate, signal = wavfile.read(f'wavfiles/{fname}')
df.at[fname, 'length'] = signal.shape[0] / rate
classes = list(np.unique(df.label))
# Get mean of length for each label
class_dist = df.groupby(['label'])['length'].mean()
# Returns figure object and axis which we customize
fig, ax = plt.subplots()
ax.set_title('Class Distribution', y=1.08)
ax.pie(class_dist, labels=class_dist.index, autopct='%1.1f%%',
shadow=False, startangle=90)
ax.axis('equal')
plt.show()Last updated