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
# Player Count# Total Number of Playersplayer_count=len(data['SN'].unique())
players_df=pd.DataFrame([{'Total Players': player_count}])
players_df.set_index('Total Players', inplace=True)
players_df
# Purchasing Analysis (Total)# Number of Unique Items# Average Purchase Price# Total Number of Purchases# Total Revenueno_dup_items=data.drop_duplicates(['Item ID'], keep='last')
total_unique=len(no_dup_items)
total_pur=data['Price'].count()
total_rev=round(data['Price'].sum(),2)
avg_price=round(total_rev/total_pur, 2)
pur_analysis=pd.DataFrame([{
"Number of Unique Items": total_unique,
'Average Purchase Price': avg_price,
'Total Purchases': total_pur,
'Total Revenue': total_rev
}])
pur_analysis.style.format({'Average Purchase Price': '${:.2f}', 'Total Revenue': '${:,.2f}'})
<style type="text/css" >
</style>
Average Purchase Price
Number of Unique Items
Total Purchases
Total Revenue
0
$2.93
183
780
$2,286.33
Gender Demographics
# Gender Demographics# Percentage and Count of Male Players# Percentage and Count of Female Players#Percentage and Count of Other / Non-Disclosedno_dup_players=data.drop_duplicates(['SN'], keep='last')
gender_counts=no_dup_players['Gender'].value_counts().reset_index()
gender_counts['% of Players'] =gender_counts['Gender']/player_count*100gender_counts.rename(columns= {'index': 'Gender', 'Gender': '# of Players'}, inplace=True)
gender_counts.set_index(['Gender'], inplace=True)
gender_counts.style.format({"% of Players": "{:.1f}%"})
<style type="text/css" >
</style>
# of Players
% of Players
Gender
Male
465
81.2%
Female
100
17.5%
Other / Non-Disclosed
8
1.4%
Purchasing Analysis (Gender)
# Purchasing Analysis (Gender)# The below each broken by gender# Purchase Count# Average Purchase Price# Total Purchase Value# Normalized Totalscount_by_gen=pd.DataFrame(data.groupby('Gender')['Gender'].count())
total_by_gen=pd.DataFrame(data.groupby('Gender')['Price'].sum())
analysis_gen=pd.merge(count_by_gen, total_by_gen, left_index=True, right_index=True)
analysis_gen.rename(columns= {'Gender': '# of Purchases', 'Price':'Total Purchase Value'}, inplace=True)
analysis_gen['Average Purchase Price'] =analysis_gen['Total Purchase Value']/analysis_gen['# of Purchases']
analysis_gen=analysis_gen.merge(gender_counts, left_index=True, right_index=True)
analysis_gen['Normalized Totals'] =analysis_gen['Total Purchase Value']/analysis_gen['# of Players']
analysis_gendelanalysis_gen['% of Players']
delanalysis_gen['# of Players']
analysis_gen.style.format({'Total Purchase Value': '${:.2f}', 'Average Purchase Price': '${:.2f}', 'Normalized Totals': '${:.2f}'})
# Top Spenders# Identify the the top 5 spenders in the game by total purchase value, then list (in a table):# SN# Purchase Count# Average Purchase Price# Total Purchase Valuepurchase_amt_by_SN=pd.DataFrame(data.groupby('SN')['Price'].sum())
num_purchase_by_SN=pd.DataFrame(data.groupby('SN')['Price'].count())
avg_purchase_by_SN=pd.DataFrame(data.groupby('SN')['Price'].mean())
merged_top5=pd.merge(purchase_amt_by_SN, num_purchase_by_SN, left_index=True, right_index=True).merge(avg_purchase_by_SN, left_index=True, right_index=True)
merged_top5.rename(columns= {'Price_x': 'Total Purchase Value', 'Price_y':'Purchase Count', 'Price':'Average Purchase Price'}, inplace=True)
merged_top5.sort_values('Total Purchase Value', ascending=False, inplace=True)
merged_top5=merged_top5.head()
merged_top5.style.format({'Total Purchase Value': '${:.2f}', 'Average Purchase Price': '${:.2f}'})
<style type="text/css" >
</style>
Total Purchase Value
Purchase Count
Average Purchase Price
SN
Undirrala66
$17.06
5
$3.41
Saedue76
$13.56
4
$3.39
Mindimnya67
$12.74
4
$3.18
Haellysu29
$12.73
3
$4.24
Eoda93
$11.58
3
$3.86
Most Popular Items
# Most Popular Items# Identify the 5 most popular items by purchase count, then list (in a table):# Item ID# Item Name# Purchase Count# Item Price# Total Purchase Valuetop5_items_ID=pd.DataFrame(data.groupby('Item ID')['Item ID'].count())
top5_items_ID.sort_values('Item ID', ascending=False, inplace=True)
top5_items_ID=top5_items_ID.iloc[0:5][:]
top5_items_total=pd.DataFrame(data.groupby('Item ID')['Price'].sum())
top5_items=pd.merge(top5_items_ID, top5_items_total, left_index=True, right_index=True)
no_dup_items=data.drop_duplicates(['Item ID'], keep='last')
top5_merge_ID=pd.merge(top5_items, no_dup_items, left_index=True, right_on='Item ID')
top5_merge_ID=top5_merge_ID[['Item ID', 'Item Name', 'Item ID_x', 'Price_y', 'Price_x']]
top5_merge_ID.set_index(['Item ID'], inplace=True)
top5_merge_ID.rename(columns= {'Item ID_x': 'Purchase Count', 'Price_y': 'Item Price', 'Price_x': 'Total Purchase Value'}, inplace=True)
top5_merge_ID.style.format({'Item Price': '${:.2f}', 'Total Purchase Value': '${:.2f}'})
<style type="text/css" >
</style>
Item Name
Purchase Count
Item Price
Total Purchase Value
Item ID
39
Betrayal, Whisper of Grieving Widows
11
$2.35
$25.85
84
Arcane Gem
11
$2.23
$24.53
31
Trickster
9
$2.07
$18.63
175
Woeful Adamantite Claymore
9
$1.24
$11.16
13
Serenity
9
$1.49
$13.41
Most Profitable Items
# Most Profitable Items# Identify the 5 most profitable items by total purchase value, then list (in a table):# Item ID# Item Name# Purchase Count# Item Price# Total Purchase Valuetop5_profit=pd.DataFrame(data.groupby('Item ID')['Price'].sum())
top5_profit.sort_values('Price', ascending=False, inplace=True)
top5_profit=top5_profit.iloc[0:5][:]
pur_count_profit=pd.DataFrame(data.groupby('Item ID')['Item ID'].count())
top5_profit=pd.merge(top5_profit, pur_count_profit, left_index=True, right_index=True, how='left')
top5_merge_profit=pd.merge(top5_profit, no_dup_items, left_index=True, right_on='Item ID', how='left')
top5_merge_profit=top5_merge_profit[['Item ID', 'Item Name', 'Item ID_x', 'Price_y','Price_x']]
top5_merge_profit.set_index(['Item ID'], inplace=True)
top5_merge_profit.rename(columns= {'Item ID_x': 'Purchase Count', 'Price_y': 'Item Price', 'Price_x': 'Total Purchase Value'}, inplace=True)
top5_merge_profit.style.format({'Item Price': '${:.2f}', 'Total Purchase Value': '${:.2f}'})