2
I’m taking the Science Data Course from Udacity. It’s my first contact with programming, so don’t judge the silly mistakes haha.
I’m comparing two data frames with information from cars of the year 2008 and 2018. One of the questions asks to compare the improvement in fuel consumption by vehicle class.
I took the consumption averages of each class using the grupby, then I played these averages in a variable and tried to create a graph to compare the evolution from one year to the next. My attempt was this:
ind = np.arange(3, 7)
width = 0.2
labels = ['SUV', 'LC', 'MC', 'Minivan', 'Pickup', 'SC', 'SW']
bar_08 = plt.bar(ind, [18.47, 18.50, 21.60, 19.11, 16.27, 21.09, 22.36], width, color='r', label=2008)
bar_18 = plt.bar(ind+width, [17.19, 22.67, 26.90, 20.80, 18.08, 24.37, 27.52], width, color='b', label=2018)
location = ind+width/2
labels=labels
plt.xticks(locatio, labels)
plt.legend()
The error that appears is as follows: Shape Mismatch: Objects cannot be broadcast to a single Shape
Can someone enlighten me in this matter?