additionally @ ‘IN 278’: (BTW rerun the cells so they start at 1 )
use groupby insted of loops(always avoid loops at all cost when it comes to going trough all dataframe, loops should be your last choice). Here’s a different approach to achieve your results, without a loop:
top20 = autos["brand"].unique()[:20] autos_20 = autos[autos["brand"].isin(top20)] autos_20.groupby('brand')['price'].mean()
Thanks man, really appreciate the feedback. I hadn’t come across the ‘groupby()’ method just yet but I will certainly be checking it out further to utilize in future projects.