Heroes of Pymoli

 

temp-162419085775753200
In [28]:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
In [29]:
purchase = pd.read_csv("purchase_data.csv")
purchase.head(5)
Out[29]:
Purchase ID SN Age Gender Item ID Item Name Price
0 0 Lisim78 20 Male 108 Extraction, Quickblade Of Trembling Hands 3.53
1 1 Lisovynya38 40 Male 143 Frenzied Scimitar 1.56
2 2 Ithergue48 24 Male 92 Final Critic 4.88
3 3 Chamassasya86 24 Male 100 Blindscythe 3.27
4 4 Iskosia90 23 Male 131 Fury 1.44
In [30]:
purchase.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 780 entries, 0 to 779
Data columns (total 7 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   Purchase ID  780 non-null    int64  
 1   SN           780 non-null    object 
 2   Age          780 non-null    int64  
 3   Gender       780 non-null    object 
 4   Item ID      780 non-null    int64  
 5   Item Name    780 non-null    object 
 6   Price        780 non-null    float64
dtypes: float64(1), int64(3), object(3)
memory usage: 42.8+ KB
In [206]:
#Total Number of Players
total_players = purchase["SN"].nunique()
total_players
Out[206]:
576
In [32]:
#Number of Unique Items
unique_items = purchase["Item Name"].nunique()
unique_items
Out[32]:
179
In [33]:
#Average Purchase Price
avg_price = purchase["Price"].mean()
avg_price
Out[33]:
3.050987179487176
In [34]:
#Total Number of Purchases

total_purchase = purchase["Purchase ID"].count()
total_purchase
Out[34]:
780
In [35]:
#Total Revenue
total_revenue = purchase["Price"].sum()
total_revenue
Out[35]:
2379.77
In [36]:
'''Percentage and Count of Male Players
Percentage and Count of Female Players
Percentage and Count of Other / Non-Disclosed'''
total_male_players = purchase[purchase["Gender"]== "Male"].Gender.count()
total_female_players = purchase[purchase["Gender"]== "Female"].Gender.count()
total_other_players = total_players - (total_male_players + total_female_players)
per_of_male = ((total_male_players*100)/total_players).round(2)
per_of_female = ((total_female_players*100)/total_players).round(2)
per_of_other = ((total_other_players*100)/total_players).round(2)

y = pd.Series({"Male": per_of_male, 
               "Female": per_of_female, 
               "Others/Non Disclosed": per_of_other})
plt.title("Gender Demographic")
y.plot(kind = "pie", figsize = (12,8),autopct='%.2f%%');
In [37]:
'''below each broken by gender
Purchase Count
Average Purchase Price
Total Purchase Value
Average Purchase Total per Person by Gender'''

purchase_count_of_male = ((total_male_players*100) /total_players).round(2)
avg_purchase_price_of_male = purchase[purchase["Gender"]== "Male"].Price.mean()
total_purchase_of_male = purchase[purchase["Gender"]== "Male"].Price.sum()
average_purchase_total_per_male = total_purchase_of_male / total_male_players
In [38]:
purchase_count_of_female = ((total_female_players*100) /total_players).round(2)
avg_purchase_price_of_female = purchase[purchase["Gender"]== "Female"].Price.mean()
total_purchase_of_female = purchase[purchase["Gender"]== "Female"].Price.sum()
average_purchase_total_per_female = total_purchase_of_female / total_female_players
In [39]:
purchase_count_of_other = ((total_other_players*100) /total_players).round(2)
avg_purchase_price_of_other = purchase[purchase["Gender"]!= ("Female" and "Male")].Price.mean()
total_purchase_of_other = purchase[purchase["Gender"]!= ("Female" and "Male")].Price.sum()
average_purchase_total_per_other = total_purchase_of_other / total_other_players
In [40]:
plt.figure(figsize=(12,8))
plt.title("Purchase Count by Gender")
plt.pie(x = [purchase_count_of_male, purchase_count_of_female, purchase_count_of_other], autopct = "%.2f%%", labels = ["Male","Female","Other/Non Disclosed"]);
In [46]:
plt.title("Purchasing Analysis(Gender)")
plt.ylabel("Avg Purchasing Price")
plt.bar(x = ["Female", "Male", "Other/Non Disclosed"], height = [avg_purchase_price_of_female,avg_purchase_price_of_male,avg_purchase_price_of_other]);
In [50]:
purchase_count_of_bin1 = purchase[purchase["Age"] < 10]["Purchase ID"].count()
avg_purchase_price_of_bin1 = purchase[purchase["Age"] < 10]["Price"].mean()
total_purchase_value_of_bin1 = purchase[purchase["Age"] <10]["Price"].sum()
avg_purchase_total_per_bin1 = total_purchase_value_of_bin1 / purchase[purchase["Age"] < 10].SN.count()
In [51]:
purchase_count_of_bin2 = purchase[purchase["Age"].between(10, 14)]["Purchase ID"].count()
avg_purchase_price_of_bin2 = purchase[purchase["Age"].between(10, 14)]["Price"].mean()
total_purchase_value_of_bin2 = purchase[purchase["Age"].between(10, 14)]["Price"].sum()
avg_purchase_total_per_bin2 = total_purchase_value_of_bin2 / purchase[purchase["Age"].between(10,14)].SN.count()
In [77]:
purchase_count_of_bin3 = purchase[purchase["Age"].between(15, 19)]["Purchase ID"].count()
avg_purchase_price_of_bin3 = purchase[purchase["Age"].between(15, 19)]["Price"].mean()
total_purchase_value_of_bin3 = purchase[purchase["Age"].between(15, 19)]["Price"].sum()
avg_purchase_total_per_bin3 = total_purchase_value_of_bin3 / purchase[purchase["Age"].between(15,19)].SN.count()
In [76]:
purchase_count_of_bin4 = purchase[purchase["Age"].between(20, 24)]["Purchase ID"].count()
avg_purchase_price_of_bin4 = purchase[purchase["Age"].between(20, 24)]["Price"].mean()
total_purchase_value_of_bin4 = purchase[purchase["Age"].between(20, 24)]["Price"].sum()
avg_purchase_total_per_bin4 = total_purchase_value_of_bin4 / purchase[purchase["Age"].between(20,24)].SN.count()
total_purchase_value_of_bin4
Out[76]:
1114.06
In [64]:
purchase_count_of_bin5 = purchase[purchase["Age"].between(25, 29)]["Purchase ID"].count()
avg_purchase_price_of_bin5 = purchase[purchase["Age"].between(25, 29)]["Price"].mean()
total_purchase_value_of_bin5 = purchase[purchase["Age"].between(25, 29)]["Price"].sum()
avg_purchase_total_per_bin5 = total_purchase_value_of_bin5 / purchase[purchase["Age"].between(25,29)].SN.count()
In [65]:
purchase_count_of_bin6 = purchase[purchase["Age"].between(30, 34)]["Purchase ID"].count()
avg_purchase_price_of_bin6 = purchase[purchase["Age"].between(30, 34)]["Price"].mean()
total_purchase_value_of_bin6 = purchase[purchase["Age"].between(30, 34)]["Price"].sum()
avg_purchase_total_per_bin6 = total_purchase_value_of_bin6 / purchase[purchase["Age"].between(30,34)].SN.count()
In [66]:
purchase_count_of_bin7 = purchase[purchase["Age"].between(35, 39)]["Purchase ID"].count()
avg_purchase_price_of_bin7 = purchase[purchase["Age"].between(35, 39)]["Price"].mean()
total_purchase_value_of_bin7 = purchase[purchase["Age"].between(35, 39)]["Price"].sum()
avg_purchase_total_per_bin7 = total_purchase_value_of_bin7 / purchase[purchase["Age"].between(35,39)].SN.count()
In [70]:
purchase_count_of_bin8 = purchase[purchase["Age"] > 40]["Purchase ID"].count()
avg_purchase_price_of_bin8 = purchase[purchase["Age"] > 40]["Price"].mean()
total_purchase_value_of_bin8 = purchase[purchase["Age"] > 40]["Price"].sum()
avg_purchase_total_per_bin8 = total_purchase_value_of_bin8 / purchase[purchase["Age"] > 40].SN.count()
In [71]:
plt.title("Age Demographic")
plt.ylabel("Count")
plt.bar(x = ["<10", "10-14", "14-19","20-24","25-29","30-34", "35-39", ">40"], height = [purchase_count_of_bin1,purchase_count_of_bin2,purchase_count_of_bin3,purchase_count_of_bin4,purchase_count_of_bin5,purchase_count_of_bin6,purchase_count_of_bin7,purchase_count_of_bin8]);
In [86]:
plt.title("Purchasing Analysis(Age)")

plt.ylabel("Avg Total Purchase Per Person")
plt.bar(x = ["<10", "10-14", "14-19","20-24","25-29","30-34", "35-39", "40+"], height = [avg_purchase_total_per_bin1,avg_purchase_total_per_bin2,avg_purchase_total_per_bin3,avg_purchase_total_per_bin4,avg_purchase_total_per_bin5,avg_purchase_total_per_bin6,avg_purchase_total_per_bin7,avg_purchase_total_per_bin8], color = ["blue","orange","green","red","violet","brown","pink","silver"]);
In [87]:
plt.title("Purchasing Analysis(Age)")

plt.ylabel("Total Purchase Value")
plt.bar(x = ["<10", "10-14", "14-19","20-24","25-29","30-34", "35-39", "40+"], height = [total_purchase_value_of_bin1,total_purchase_value_of_bin2,total_purchase_value_of_bin3,total_purchase_value_of_bin4,total_purchase_value_of_bin5,total_purchase_value_of_bin6,total_purchase_value_of_bin7,total_purchase_value_of_bin8], color = ["blue","orange","green","red","violet","brown","pink","silver"]);
In [93]:
#TOP 5 Spender
top_five =purchase.sort_values(by = "Price", ascending = False).head(5)
top_five
Out[93]:
Purchase ID SN Age Gender Item ID Item Name Price
554 554 Dyally87 22 Male 63 Stormfury Mace 4.99
189 189 Hiasri33 23 Male 63 Stormfury Mace 4.99
110 110 Ririp86 25 Male 139 Mercy, Katana of Dismay 4.94
246 246 Lirtilsa71 24 Male 139 Mercy, Katana of Dismay 4.94
493 493 Chanirrasta87 14 Male 139 Mercy, Katana of Dismay 4.94
In [159]:
#5 most popular items by purchase count
purchase["Item Name"].value_counts()
Out[159]:
Final Critic                                    13
Oathbreaker, Last Hope of the Breaking Storm    12
Persuasion                                       9
Fiery Glass Crusader                             9
Nirvana                                          9
                                                ..
Gladiator's Glaive                               1
Riddle, Tribute of Ended Dreams                  1
Undead Crusader                                  1
Alpha, Reach of Ending Hope                      1
Endbringer                                       1
Name: Item Name, Length: 179, dtype: int64
In [173]:
#5 most profitable items by total purchase value
purchase.sort_values("Price", ascending = False)
Out[173]:
Purchase ID SN Age Gender Item ID Item Name Price
554 554 Dyally87 22 Male 63 Stormfury Mace 4.99
189 189 Hiasri33 23 Male 63 Stormfury Mace 4.99
110 110 Ririp86 25 Male 139 Mercy, Katana of Dismay 4.94
246 246 Lirtilsa71 24 Male 139 Mercy, Katana of Dismay 4.94
493 493 Chanirrasta87 14 Male 139 Mercy, Katana of Dismay 4.94
... ... ... ... ... ... ... ...
586 586 Chanirra79 23 Female 155 War-Forged Gold Deflector 1.01
282 282 Aidai61 21 Male 155 War-Forged Gold Deflector 1.01
371 371 Eusurdeu49 23 Male 155 War-Forged Gold Deflector 1.01
63 63 Alo38 20 Male 125 Whistling Mithril Warblade 1.00
418 418 Marim28 25 Female 125 Whistling Mithril Warblade 1.00

780 rows × 7 columns

In [ ]:

In [ ]:

In [ ]:

In [ ]:

Comments