Hello world,
No faulty code to show today. I’m a bit confused on step 8 of the Communicating Results course though, and I’m surprised no one seems to have said anything about this step yet - I might just be missing something. In the mission, a new Results column is generated at the beginning, and then seemingly not used again when calculating the impact of changing app prices. Shouldn’t this column be used to calculate which apps we are actually interested in counting? Otherwise the whole section about majority voting seems useless…
Here is a link to the mission:
And the solution code provided:
criteria = ["price_criterion", "genre_criterion", "category_criterion"]
affordable_apps["Result"] = affordable_apps[criteria].mode(axis='columns')
def new_price(row):
if row["affordability"] == "cheap":
return round(max(row["Price"], cheap_mean), 2)
else:
return round(max(row["Price"], reasonable_mean), 2)
affordable_apps["New Price"] = affordable_apps.apply(new_price, axis="columns")
affordable_apps["Installs"] = affordable_apps["Installs"].str.replace("[+,]", "").astype(int)
affordable_apps["Impact"] = (affordable_apps["New Price"]-affordable_apps["Price"])*affordable_apps["Installs"]
total_impact = affordable_apps["Impact"].sum()
print(total_impact)