As you can see my top 6 brands are a little different than the ones provided in the next mission. If you look at my output, I have ‘sonstige_autos’, ‘mini’ and ‘skoda’ in the top 6. Can you please explain what I did wrong? Thanks
Screen Link: https://app.dataquest.io/m/294/guided-project%3A-exploring-ebay-car-sales-data/7/exploring-price-by-brand
My Code:
top_brand = autos['brand'].value_counts().sort_values(ascending=False).head(20).index
brand_mean_price = {}
for value in top_brand:
brand_row = autos[autos['brand'] == value]
mean = brand_row['price_$'].mean()
brand_mean_price[value] = int(mean)
#sorting the brand_mean_price
sorted_mean = sorted(brand_mean_price.items(), key=lambda x: x[1], reverse=True)
for i in sorted_mean:
print(i[0],':',i[1])
What I expected to happen:
audi 9336
bmw 8332
ford 3749
mercedes_benz 8628
opel 2975
volkswagen 5402
dtype: int64
What actually happened:
sonstige_autos : 12365
mini : 10613
audi : 9336
mercedes_benz : 8628
bmw : 8332
skoda : 6368
volkswagen : 5402
hyundai : 5365
toyota : 5167
volvo : 4946
nissan : 4743
seat : 4397
mazda : 4112
citroen : 3779
ford : 3749
smart : 3580
peugeot : 3094
opel : 2976
fiat : 2813