You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
temp_df=pd.DataFrame()
# * Number of Unique Itemsunique_items=len(data['Item ID'].unique())
temp_df["Number of Unique Items"] = [unique_items]
# * Average Purchase Priceavg_price=round(data["Price"].mean(), 2)
temp_df["Average Purchase Price"] =avg_price# * Total Number of Purchasestotal_purchases=len(data)
temp_df["Total Purchases"] =total_purchases# * Total Revenuetotal_revenue=round(data["Price"].sum(), 2)
temp_df["Total Revenue"] =total_revenuetemp_df
# Removing duplicate players from the datadata_without_duplicate_players=data.drop_duplicates(subset=["SN"])
# Seperating the no duplicate data into gender groupsgender_groups=data_without_duplicate_players["Gender"].value_counts()
# Printing Percentage of palyers and total count according to their genderx=pd.DataFrame({"Total Count":gender_groups,
"Percentage of Players": round(gender_groups/unique_players*100, 2)})
x
# Number of purchases by each gendergrouped_data=data.groupby(["Gender"])
purchases=pd.DataFrame()
forgender, infoingrouped_data:
price_column=info["Price"]
purchase=pd.DataFrame({
"Total Purchases" : [len(info)],
"Average Purchase Price" : [round(price_column.mean(), 2)],
"Total Purchase Value" : [price_column.sum()]
}, index=[gender])
purchases=purchases.append(purchase)
# TODO : Figure out how to calculate Normalized Totalspurchases
# TODO: Need to Redo - Incorrect# Number of purchases by each gendergrouped_data=data.groupby(["Age"])
purchases=pd.DataFrame()
forage, infoingrouped_data:
price_column=info["Price"]
purchase=pd.DataFrame({
"Total Purchases" : [len(info)],
"Average Purchase Price" : [round(price_column.mean(), 2)],
"Total Purchase Value" : [price_column.sum()]
}, index=[age])
purchases=purchases.append(purchase)
# TODO : Figure out how to calculate Normalized Totalspurchases
# Grouping the players and their purchases. grouped_players=data.groupby(["SN"])
players_info=pd.DataFrame()
# Going through every player and storing important valuesforname, infoingrouped_players:
price_column=info["Price"]
spender_info=pd.DataFrame({
'Purchase Count': [len(price_column)],
'Average Purchase Price' : [price_column.mean()],
'Total Purchase Value' : [price_column.sum()]
}, index=[name])
# Need to store append value back into players_info because the person who wrote append was retartedplayers_info=players_info.append(spender_info, ignore_index=False)
top_5_spenders=players_info.sort_values(by="Total Purchase Value", ascending=False).head()
top_5_spenders.style.format({'Total Purchase Value': '${:.2f}', 'Average Purchase Price': '${:.2f}'})