Skip to content

jwynnsmith/Python_Pandas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#Dependencies\n", "import pandas as pd\n", "import numpy as np\n", "#from sklearn.preprocessing import MinMaxScalar\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 269, "metadata": {}, "outputs": [ { "data": { "text/html": [ "

\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Player ID\n", " SN\n", " Age\n", " Gender\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Marughi89\n", " 21\n", " Male\n", " \n", " \n", " 1\n", " 1\n", " Lirtedy26\n", " 40\n", " Male\n", " \n", " \n", " 2\n", " 2\n", " Chamistast30\n", " 7\n", " Male\n", " \n", " \n", " 3\n", " 3\n", " Lisirra25\n", " 24\n", " Male\n", " \n", " \n", " 4\n", " 4\n", " Lirtim36\n", " 23\n", " Male\n", " \n", " \n", " 5\n", " 5\n", " Undimsya85\n", " 17\n", " Female\n", " \n", " \n", " 6\n", " 6\n", " Lirtassa77\n", " 20\n", " Female\n", " \n", " \n", " 7\n", " 7\n", " Mindirra92\n", " 23\n", " Male\n", " \n", " \n", " 8\n", " 8\n", " Undirrasta89\n", " 23\n", " Male\n", " \n", " \n", " 9\n", " 9\n", " Iskjaskst81\n", " 15\n", " Male\n", " \n", " \n", " 10\n", " 10\n", " Yoishirrala98\n", " 22\n", " Male\n", " \n", " \n", " 11\n", " 11\n", " Undassa89\n", " 22\n", " Male\n", " \n", " \n", " 12\n", " 12\n", " Lisossanya98\n", " 22\n", " Male\n", " \n", " \n", " 13\n", " 13\n", " Lisirra87\n", " 7\n", " Female\n", " \n", " \n", " 14\n", " 14\n", " Ililsan66\n", " 7\n", " Male\n", " \n", " \n", " 15\n", " 15\n", " Lisosiast26\n", " 24\n", " Male\n", " \n", " \n", " 16\n", " 16\n", " Ilimya66\n", " 18\n", " Male\n", " \n", " \n", " 17\n", " 17\n", " Lisassa49\n", " 21\n", " Female\n", " \n", " \n", " 18\n", " 18\n", " Mindirraya69\n", " 25\n", " Male\n", " \n", " \n", " 19\n", " 19\n", " Lirtista72\n", " 21\n", " Male\n", " \n", " \n", " 20\n", " 20\n", " Sondassala75\n", " 27\n", " Male\n", " \n", " \n", " 21\n", " 21\n", " Iskelosda54\n", " 20\n", " Male\n", " \n", " \n", " 22\n", " 22\n", " Sundista85\n", " 31\n", " Female\n", " \n", " \n", " 23\n", " 23\n", " Lirtossa84\n", " 18\n", " Male\n", " \n", " \n", " 24\n", " 24\n", " Chanjasksda31\n", " 33\n", " Male\n", " \n", " \n", " 25\n", " 25\n", " Chamiman85\n", " 15\n", " Male\n", " \n", " \n", " 26\n", " 26\n", " Lisosia66\n", " 24\n", " Male\n", " \n", " \n", " 27\n", " 27\n", " Lisirra44\n", " 21\n", " Male\n", " \n", " \n", " 28\n", " 28\n", " Mindassast27\n", " 20\n", " Male\n", " \n", " \n", " 29\n", " 29\n", " Quilassa66\n", " 22\n", " Female\n", " \n", " \n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " \n", " \n", " 170\n", " 170\n", " Jiskjask76\n", " 28\n", " Male\n", " \n", " \n", " 171\n", " 171\n", " Lisjasksda68\n", " 19\n", " Male\n", " \n", " \n", " 172\n", " 172\n", " Assjaskan73\n", " 25\n", " Female\n", " \n", " \n", " 173\n", " 173\n", " Jiskilsa35\n", " 26\n", " Male\n", " \n", " \n", " 174\n", " 174\n", " Lirtosia72\n", " 16\n", " Male\n", " \n", " \n", " 175\n", " 175\n", " Lisassa26\n", " 25\n", " Male\n", " \n", " \n", " 176\n", " 176\n", " Undadar97\n", " 25\n", " Male\n", " \n", " \n", " 177\n", " 177\n", " Jiskirran77\n", " 20\n", " Female\n", " \n", " \n", " 178\n", " 178\n", " Iladarla40\n", " 23\n", " Female\n", " \n", " \n", " 179\n", " 179\n", " Lisista54\n", " 11\n", " Female\n", " \n", " \n", " 180\n", " 180\n", " Chamista31\n", " 35\n", " Male\n", " \n", " \n", " 181\n", " 181\n", " Chanosiast43\n", " 27\n", " Male\n", " \n", " \n", " 182\n", " 182\n", " Lirtassa52\n", " 42\n", " Female\n", " \n", " \n", " 183\n", " 183\n", " Lassirrasda85\n", " 30\n", " Female\n", " \n", " \n", " 184\n", " 184\n", " Undirra73\n", " 22\n", " Male\n", " \n", " \n", " 185\n", " 185\n", " Sondassa68\n", " 24\n", " Male\n", " \n", " \n", " 186\n", " 186\n", " Sondilsa42\n", " 20\n", " Male\n", " \n", " \n", " 187\n", " 187\n", " Undilsa52\n", " 31\n", " Male\n", " \n", " \n", " 188\n", " 188\n", " Assylla81\n", " 20\n", " Male\n", " \n", " \n", " 189\n", " 189\n", " Koikirra25\n", " 25\n", " Male\n", " \n", " \n", " 190\n", " 190\n", " Lisirra58\n", " 11\n", " Male\n", " \n", " \n", " 191\n", " 191\n", " Jiskebosya95\n", " 22\n", " Other / Non-Disclosed\n", " \n", " \n", " 192\n", " 192\n", " Chadassasda60\n", " 22\n", " Male\n", " \n", " \n", " 193\n", " 193\n", " Jiskimsta59\n", " 10\n", " Male\n", " \n", " \n", " 194\n", " 194\n", " Lisimsta66\n", " 20\n", " Male\n", " \n", " \n", " 195\n", " 195\n", " Jiskossa51\n", " 23\n", " Male\n", " \n", " \n", " 196\n", " 196\n", " Sondadarya58\n", " 18\n", " Male\n", " \n", " \n", " 197\n", " 197\n", " Ilosiast59\n", " 28\n", " Male\n", " \n", " \n", " 198\n", " 198\n", " Chanossala89\n", " 19\n", " Male\n", " \n", " \n", " 199\n", " 199\n", " Frichistasta59\n", " 23\n", " Male\n", " \n", " \n", "\n", "

200 rows Ă— 4 columns

\n", "
" ], "text/plain": [ " Player ID SN Age Gender\n", "0 0 Marughi89 21 Male\n", "1 1 Lirtedy26 40 Male\n", "2 2 Chamistast30 7 Male\n", "3 3 Lisirra25 24 Male\n", "4 4 Lirtim36 23 Male\n", "5 5 Undimsya85 17 Female\n", "6 6 Lirtassa77 20 Female\n", "7 7 Mindirra92 23 Male\n", "8 8 Undirrasta89 23 Male\n", "9 9 Iskjaskst81 15 Male\n", "10 10 Yoishirrala98 22 Male\n", "11 11 Undassa89 22 Male\n", "12 12 Lisossanya98 22 Male\n", "13 13 Lisirra87 7 Female\n", "14 14 Ililsan66 7 Male\n", "15 15 Lisosiast26 24 Male\n", "16 16 Ilimya66 18 Male\n", "17 17 Lisassa49 21 Female\n", "18 18 Mindirraya69 25 Male\n", "19 19 Lirtista72 21 Male\n", "20 20 Sondassala75 27 Male\n", "21 21 Iskelosda54 20 Male\n", "22 22 Sundista85 31 Female\n", "23 23 Lirtossa84 18 Male\n", "24 24 Chanjasksda31 33 Male\n", "25 25 Chamiman85 15 Male\n", "26 26 Lisosia66 24 Male\n", "27 27 Lisirra44 21 Male\n", "28 28 Mindassast27 20 Male\n", "29 29 Quilassa66 22 Female\n", ".. ... ... ... ...\n", "170 170 Jiskjask76 28 Male\n", "171 171 Lisjasksda68 19 Male\n", "172 172 Assjaskan73 25 Female\n", "173 173 Jiskilsa35 26 Male\n", "174 174 Lirtosia72 16 Male\n", "175 175 Lisassa26 25 Male\n", "176 176 Undadar97 25 Male\n", "177 177 Jiskirran77 20 Female\n", "178 178 Iladarla40 23 Female\n", "179 179 Lisista54 11 Female\n", "180 180 Chamista31 35 Male\n", "181 181 Chanosiast43 27 Male\n", "182 182 Lirtassa52 42 Female\n", "183 183 Lassirrasda85 30 Female\n", "184 184 Undirra73 22 Male\n", "185 185 Sondassa68 24 Male\n", "186 186 Sondilsa42 20 Male\n", "187 187 Undilsa52 31 Male\n", "188 188 Assylla81 20 Male\n", "189 189 Koikirra25 25 Male\n", "190 190 Lisirra58 11 Male\n", "191 191 Jiskebosya95 22 Other / Non-Disclosed\n", "192 192 Chadassasda60 22 Male\n", "193 193 Jiskimsta59 10 Male\n", "194 194 Lisimsta66 20 Male\n", "195 195 Jiskossa51 23 Male\n", "196 196 Sondadarya58 18 Male\n", "197 197 Ilosiast59 28 Male\n", "198 198 Chanossala89 19 Male\n", "199 199 Frichistasta59 23 Male\n", "\n", "[200 rows x 4 columns]" ] }, "execution_count": 269, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Load csv file\n", "\n", "players_file = "players_complete.csv"\n", "items_file = "items_complete.csv"\n", "purchase_file = "purchase_data_3.csv"\n", "\n", "players_df = pd.read_csv(players_file)\n", "items_df = pd.read_csv(items_file)\n", "purchase_df = pd.read_csv(purchase_file)\n", "\n", "players_df.head(200)" ] }, { "cell_type": "code", "execution_count": 270, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Item ID\n", " Item Name\n", " Price\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Splinter\n", " 1.89\n", " \n", " \n", " 1\n", " 1\n", " Crucifer\n", " 3.67\n", " \n", " \n", " 2\n", " 2\n", " Verdict\n", " 2.65\n", " \n", " \n", " 3\n", " 3\n", " Phantomlight\n", " 4.15\n", " \n", " \n", " 4\n", " 4\n", " Bloodlord's Fetish\n", " 1.91\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Item ID Item Name Price\n", "0 0 Splinter 1.89\n", "1 1 Crucifer 3.67\n", "2 2 Verdict 2.65\n", "3 3 Phantomlight 4.15\n", "4 4 Bloodlord's Fetish 1.91" ] }, "execution_count": 270, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Items Data Frame\n", "items_df.head()" ] }, { "cell_type": "code", "execution_count": 271, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Purchase ID\n", " SN\n", " Age\n", " Gender\n", " Item ID\n", " Item Name\n", " Price\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Iloni35\n", " 20\n", " Male\n", " 93\n", " Apocalyptic Battlescythe\n", " 4.49\n", " \n", " \n", " 1\n", " 1\n", " Aidaira26\n", " 21\n", " Male\n", " 12\n", " Dawne\n", " 3.36\n", " \n", " \n", " 2\n", " 2\n", " Irim47\n", " 17\n", " Male\n", " 5\n", " Putrid Fan\n", " 2.63\n", " \n", " \n", " 3\n", " 3\n", " Irith83\n", " 17\n", " Male\n", " 123\n", " Twilight's Carver\n", " 2.55\n", " \n", " \n", " 4\n", " 4\n", " Philodil43\n", " 22\n", " Male\n", " 154\n", " Feral Katana\n", " 4.11\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Purchase ID SN Age Gender Item ID Item Name \\n", "0 0 Iloni35 20 Male 93 Apocalyptic Battlescythe \n", "1 1 Aidaira26 21 Male 12 Dawne \n", "2 2 Irim47 17 Male 5 Putrid Fan \n", "3 3 Irith83 17 Male 123 Twilight's Carver \n", "4 4 Philodil43 22 Male 154 Feral Katana \n", "\n", " Price \n", "0 4.49 \n", "1 3.36 \n", "2 2.63 \n", "3 2.55 \n", "4 4.11 " ] }, "execution_count": 271, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Purchase Data Frame\n", "purchase_df.head()" ] }, { "cell_type": "code", "execution_count": 272, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1163" ] }, "execution_count": 272, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Total number of players\n", "\n", "players_df["Player ID"].count()" ] }, { "cell_type": "code", "execution_count": 273, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Final Critic 2\n", "Persuasion 2\n", "Crucifer 2\n", "Stormcaller 2\n", "Thirsty Iron Reaver 1\n", "Souleater 1\n", "Dawn 1\n", "Wolf, Promise of the Moonwalker 1\n", "The Decapitator 1\n", "Sleepwalker 1\n", "Agatha 1\n", "Solitude's Reaver 1\n", "Expiration, Warscythe Of Lost Worlds 1\n", "Darkheart 1\n", "Splitter, Foe Of Subtlety 1\n", "Warped Diamond Crusader 1\n", "Warped Fetish 1\n", "Rage, Legacy of the Lone Victor 1\n", "Stormfury Lantern 1\n", "Shadow Strike, Glory of Ending Hope 1\n", "Bloodcursed Skeletal Protector 1\n", "Singed Onyx Warscythe 1\n", "Unending Tyranny 1\n", "Soul-Forged Steel Shortsword 1\n", "Malice, Legacy of the Queen 1\n", "Victor Iron Spikes 1\n", "Arcane Gem 1\n", "Foul Titanium Battle Axe 1\n", "Mercy, Katana of Dismay 1\n", "Blade of the Grave 1\n", " ..\n", "Retribution Axe 1\n", "Yearning Mageblade 1\n", "Netherbane 1\n", "Glinting Glass Edge 1\n", "Scalpel 1\n", "Sun Strike, Jaws of Twisted Visions 1\n", "Bone Crushing Silver Skewer 1\n", "Splinter 1\n", "Conqueror Adamantite Mace 1\n", "War-Forged Gold Deflector 1\n", "Rusty Skull 1\n", "Winter's Bite 1\n", "Celeste, Incarnation of the Corrupted 1\n", "Frenzied Scimitar 1\n", "Spectral Diamond Doomblade 1\n", "Severance 1\n", "Exiled Doomblade 1\n", "Extraction, Quickblade Of Trembling Hands 1\n", "Oathbreaker, Last Hope of the Breaking Storm 1\n", "Devine 1\n", "Endbringer 1\n", "Chaos, Ender of the End 1\n", "Torchlight, Bond of Storms 1\n", "Hellreaver, Heirloom of Inception 1\n", "Mercenary Sabre 1\n", "Heartless Bone Dualblade 1\n", "Betrayal, Whisper of Grieving Widows 1\n", "Vindictive Glass Edge 1\n", "Hope's End 1\n", "Brimstone 1\n", "Name: Item Name, Length: 186, dtype: int64" ] }, "execution_count": 273, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Number of unique items using function nunique\n", "\n", "item_ct = items_df["Item Name"].nunique()\n", "\n", "items_df["Item Name"].value_counts()" ] }, { "cell_type": "code", "execution_count": 274, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2.92" ] }, "execution_count": 274, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Average Purchase Price\n", "\n", "avg_item_price = round(purchase_df["Price"].mean(),2)\n", "avg_item_price" ] }, { "cell_type": "code", "execution_count": 275, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "78" ] }, "execution_count": 275, "metadata": {}, "output_type": "execute_result" } ], "source": [ "purchase_ct = purchase_df["Price"].count()\n", "purchase_ct" ] }, { "cell_type": "code", "execution_count": 276, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "228.1" ] }, "execution_count": 276, "metadata": {}, "output_type": "execute_result" } ], "source": [ "total_rev = round(purchase_df["Price"].sum(),2)\n", "total_rev" ] }, { "cell_type": "code", "execution_count": 277, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Number of Unique Items\n", " Average Item Price\n", " Number of Purchases\n", " Total Revenue\n", " \n", " \n", " \n", " \n", " 0\n", " 186\n", " 2.92\n", " 78\n", " 228.1\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Number of Unique Items Average Item Price Number of Purchases \\n", "0 186 2.92 78 \n", "\n", " Total Revenue \n", "0 228.1 " ] }, "execution_count": 277, "metadata": {}, "output_type": "execute_result" } ], "source": [ "summary_table_df = pd.DataFrame({\n", " "Number of Unique Items":[item_ct],\n", " "Average Item Price":[avg_item_price],\n", " "Number of Purchases":[purchase_ct],\n", " "Total Revenue":[total_rev]\n", "})\n", "summary_table_df" ] }, { "cell_type": "code", "execution_count": 278, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Player ID\n", " SN\n", " Age\n", " Gender\n", " \n", " \n", " \n", " \n", " 5\n", " 5\n", " Undimsya85\n", " 17\n", " Female\n", " \n", " \n", " 6\n", " 6\n", " Lirtassa77\n", " 20\n", " Female\n", " \n", " \n", " 13\n", " 13\n", " Lisirra87\n", " 7\n", " Female\n", " \n", " \n", " 17\n", " 17\n", " Lisassa49\n", " 21\n", " Female\n", " \n", " \n", " 22\n", " 22\n", " Sundista85\n", " 31\n", " Female\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Player ID SN Age Gender\n", "5 5 Undimsya85 17 Female\n", "6 6 Lirtassa77 20 Female\n", "13 13 Lisirra87 7 Female\n", "17 17 Lisassa49 21 Female\n", "22 22 Sundista85 31 Female" ] }, "execution_count": 278, "metadata": {}, "output_type": "execute_result" } ], "source": [ "female_df = players_df.loc[players_df["Gender"] == "Female", :]\n", "female_df.head()" ] }, { "cell_type": "code", "execution_count": 279, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Player ID\n", " SN\n", " Age\n", " Gender\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Marughi89\n", " 21\n", " Male\n", " \n", " \n", " 1\n", " 1\n", " Lirtedy26\n", " 40\n", " Male\n", " \n", " \n", " 2\n", " 2\n", " Chamistast30\n", " 7\n", " Male\n", " \n", " \n", " 3\n", " 3\n", " Lisirra25\n", " 24\n", " Male\n", " \n", " \n", " 4\n", " 4\n", " Lirtim36\n", " 23\n", " Male\n", " \n", " \n", " 7\n", " 7\n", " Mindirra92\n", " 23\n", " Male\n", " \n", " \n", " 8\n", " 8\n", " Undirrasta89\n", " 23\n", " Male\n", " \n", " \n", " 9\n", " 9\n", " Iskjaskst81\n", " 15\n", " Male\n", " \n", " \n", " 10\n", " 10\n", " Yoishirrala98\n", " 22\n", " Male\n", " \n", " \n", " 11\n", " 11\n", " Undassa89\n", " 22\n", " Male\n", " \n", " \n", " 12\n", " 12\n", " Lisossanya98\n", " 22\n", " Male\n", " \n", " \n", " 14\n", " 14\n", " Ililsan66\n", " 7\n", " Male\n", " \n", " \n", " 15\n", " 15\n", " Lisosiast26\n", " 24\n", " Male\n", " \n", " \n", " 16\n", " 16\n", " Ilimya66\n", " 18\n", " Male\n", " \n", " \n", " 18\n", " 18\n", " Mindirraya69\n", " 25\n", " Male\n", " \n", " \n", " 19\n", " 19\n", " Lirtista72\n", " 21\n", " Male\n", " \n", " \n", " 20\n", " 20\n", " Sondassala75\n", " 27\n", " Male\n", " \n", " \n", " 21\n", " 21\n", " Iskelosda54\n", " 20\n", " Male\n", " \n", " \n", " 23\n", " 23\n", " Lirtossa84\n", " 18\n", " Male\n", " \n", " \n", " 24\n", " 24\n", " Chanjasksda31\n", " 33\n", " Male\n", " \n", " \n", " 25\n", " 25\n", " Chamiman85\n", " 15\n", " Male\n", " \n", " \n", " 26\n", " 26\n", " Lisosia66\n", " 24\n", " Male\n", " \n", " \n", " 27\n", " 27\n", " Lisirra44\n", " 21\n", " Male\n", " \n", " \n", " 28\n", " 28\n", " Mindassast27\n", " 20\n", " Male\n", " \n", " \n", " 32\n", " 32\n", " Assim38\n", " 30\n", " Male\n", " \n", " \n", " 33\n", " 33\n", " Sondenasta63\n", " 34\n", " Male\n", " \n", " \n", " 34\n", " 34\n", " Chrathybust28\n", " 21\n", " Male\n", " \n", " \n", " 35\n", " 35\n", " Sondadar26\n", " 25\n", " Male\n", " \n", " \n", " 36\n", " 36\n", " Chanjaskan89\n", " 25\n", " Male\n", " \n", " \n", " 38\n", " 38\n", " Chadossa26\n", " 29\n", " Male\n", " \n", " \n", " ...\n", " ...\n", " ...\n", " ...\n", " ...\n", " \n", " \n", " 94\n", " 94\n", " Sundadar27\n", " 21\n", " Male\n", " \n", " \n", " 95\n", " 95\n", " Iskassa50\n", " 15\n", " Male\n", " \n", " \n", " 96\n", " 96\n", " Chamirra53\n", " 25\n", " Male\n", " \n", " \n", " 97\n", " 97\n", " Frichosiala98\n", " 28\n", " Male\n", " \n", " \n", " 100\n", " 100\n", " Lirtastsya71\n", " 20\n", " Male\n", " \n", " \n", " 101\n", " 101\n", " Frichistast39\n", " 18\n", " Male\n", " \n", " \n", " 103\n", " 103\n", " Sundista37\n", " 26\n", " Male\n", " \n", " \n", " 104\n", " 104\n", " Lirtilsan89\n", " 26\n", " Male\n", " \n", " \n", " 106\n", " 106\n", " Sundastnya66\n", " 21\n", " Male\n", " \n", " \n", " 107\n", " 107\n", " Chadossa89\n", " 25\n", " Male\n", " \n", " \n", " 109\n", " 109\n", " Lisjaskan36\n", " 20\n", " Male\n", " \n", " \n", " 110\n", " 110\n", " Chadistaya75\n", " 31\n", " Male\n", " \n", " \n", " 111\n", " 111\n", " Chamucosda93\n", " 27\n", " Male\n", " \n", " \n", " 112\n", " 112\n", " Chadadarla74\n", " 21\n", " Male\n", " \n", " \n", " 114\n", " 114\n", " Frichistan93\n", " 13\n", " Male\n", " \n", " \n", " 115\n", " 115\n", " Jiskassan80\n", " 25\n", " Male\n", " \n", " \n", " 116\n", " 116\n", " Raysistast71\n", " 10\n", " Male\n", " \n", " \n", " 117\n", " 117\n", " Undosia27\n", " 25\n", " Male\n", " \n", " \n", " 118\n", " 118\n", " Jiskassa76\n", " 38\n", " Male\n", " \n", " \n", " 119\n", " 119\n", " Marirrasta30\n", " 40\n", " Male\n", " \n", " \n", " 120\n", " 120\n", " Lassista97\n", " 8\n", " Male\n", " \n", " \n", " 121\n", " 121\n", " Lirtastan49\n", " 25\n", " Male\n", " \n", " \n", " 123\n", " 123\n", " Sondjasknya45\n", " 29\n", " Male\n", " \n", " \n", " 124\n", " 124\n", " Undirrala66\n", " 25\n", " Male\n", " \n", " \n", " 125\n", " 125\n", " Ilast55\n", " 13\n", " Male\n", " \n", " \n", " 126\n", " 126\n", " Iskjaskan81\n", " 35\n", " Male\n", " \n", " \n", " 127\n", " 127\n", " Iljask75\n", " 30\n", " Male\n", " \n", " \n", " 128\n", " 128\n", " Lisast98\n", " 24\n", " Male\n", " \n", " \n", " 129\n", " 129\n", " Lisilsa68\n", " 25\n", " Male\n", " \n", " \n", " 130\n", " 130\n", " Lassilsala30\n", " 21\n", " Male\n", " \n", " \n", "\n", "

100 rows Ă— 4 columns

\n", "
" ], "text/plain": [ " Player ID SN Age Gender\n", "0 0 Marughi89 21 Male\n", "1 1 Lirtedy26 40 Male\n", "2 2 Chamistast30 7 Male\n", "3 3 Lisirra25 24 Male\n", "4 4 Lirtim36 23 Male\n", "7 7 Mindirra92 23 Male\n", "8 8 Undirrasta89 23 Male\n", "9 9 Iskjaskst81 15 Male\n", "10 10 Yoishirrala98 22 Male\n", "11 11 Undassa89 22 Male\n", "12 12 Lisossanya98 22 Male\n", "14 14 Ililsan66 7 Male\n", "15 15 Lisosiast26 24 Male\n", "16 16 Ilimya66 18 Male\n", "18 18 Mindirraya69 25 Male\n", "19 19 Lirtista72 21 Male\n", "20 20 Sondassala75 27 Male\n", "21 21 Iskelosda54 20 Male\n", "23 23 Lirtossa84 18 Male\n", "24 24 Chanjasksda31 33 Male\n", "25 25 Chamiman85 15 Male\n", "26 26 Lisosia66 24 Male\n", "27 27 Lisirra44 21 Male\n", "28 28 Mindassast27 20 Male\n", "32 32 Assim38 30 Male\n", "33 33 Sondenasta63 34 Male\n", "34 34 Chrathybust28 21 Male\n", "35 35 Sondadar26 25 Male\n", "36 36 Chanjaskan89 25 Male\n", "38 38 Chadossa26 29 Male\n", ".. ... ... ... ...\n", "94 94 Sundadar27 21 Male\n", "95 95 Iskassa50 15 Male\n", "96 96 Chamirra53 25 Male\n", "97 97 Frichosiala98 28 Male\n", "100 100 Lirtastsya71 20 Male\n", "101 101 Frichistast39 18 Male\n", "103 103 Sundista37 26 Male\n", "104 104 Lirtilsan89 26 Male\n", "106 106 Sundastnya66 21 Male\n", "107 107 Chadossa89 25 Male\n", "109 109 Lisjaskan36 20 Male\n", "110 110 Chadistaya75 31 Male\n", "111 111 Chamucosda93 27 Male\n", "112 112 Chadadarla74 21 Male\n", "114 114 Frichistan93 13 Male\n", "115 115 Jiskassan80 25 Male\n", "116 116 Raysistast71 10 Male\n", "117 117 Undosia27 25 Male\n", "118 118 Jiskassa76 38 Male\n", "119 119 Marirrasta30 40 Male\n", "120 120 Lassista97 8 Male\n", "121 121 Lirtastan49 25 Male\n", "123 123 Sondjasknya45 29 Male\n", "124 124 Undirrala66 25 Male\n", "125 125 Ilast55 13 Male\n", "126 126 Iskjaskan81 35 Male\n", "127 127 Iljask75 30 Male\n", "128 128 Lisast98 24 Male\n", "129 129 Lisilsa68 25 Male\n", "130 130 Lassilsala30 21 Male\n", "\n", "[100 rows x 4 columns]" ] }, "execution_count": 279, "metadata": {}, "output_type": "execute_result" } ], "source": [ "male_df = players_df.loc[players_df["Gender"] == "Male", :]\n", "male_df.head(100)" ] }, { "cell_type": "code", "execution_count": 280, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['Male', 'Female', 'Other / Non-Disclosed'], dtype=object)" ] }, "execution_count": 280, "metadata": {}, "output_type": "execute_result" } ], "source": [ "other_df = players_df["Gender"].unique()\n", "other_df" ] }, { "cell_type": "code", "execution_count": 281, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Player ID\n", " SN\n", " Age\n", " Gender\n", " \n", " \n", " \n", " \n", " 31\n", " 31\n", " Lisossa63\n", " 24\n", " Other / Non-Disclosed\n", " \n", " \n", " 59\n", " 59\n", " Lisastsya37\n", " 16\n", " Other / Non-Disclosed\n", " \n", " \n", " 108\n", " 108\n", " Iskast78\n", " 20\n", " Other / Non-Disclosed\n", " \n", " \n", " 191\n", " 191\n", " Jiskebosya95\n", " 22\n", " Other / Non-Disclosed\n", " \n", " \n", " 249\n", " 249\n", " Undosian29\n", " 19\n", " Other / Non-Disclosed\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Player ID SN Age Gender\n", "31 31 Lisossa63 24 Other / Non-Disclosed\n", "59 59 Lisastsya37 16 Other / Non-Disclosed\n", "108 108 Iskast78 20 Other / Non-Disclosed\n", "191 191 Jiskebosya95 22 Other / Non-Disclosed\n", "249 249 Undosian29 19 Other / Non-Disclosed" ] }, "execution_count": 281, "metadata": {}, "output_type": "execute_result" } ], "source": [ "other_nd_df = players_df.loc[players_df["Gender"] == "Other / Non-Disclosed", :]\n", "other_nd_df.head()" ] }, { "cell_type": "code", "execution_count": 282, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "22" ] }, "execution_count": 282, "metadata": {}, "output_type": "execute_result" } ], "source": [ "other_nd_ct = other_nd_df["Gender"].count()\n", "other_nd_ct" ] }, { "cell_type": "code", "execution_count": 283, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "82.03" ] }, "execution_count": 283, "metadata": {}, "output_type": "execute_result" } ], "source": [ "percent_m = round((male_df["Gender"].count()/players_df["Gender"].count())*100, 2)\n", "percent_m" ] }, { "cell_type": "code", "execution_count": 284, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "16.08" ] }, "execution_count": 284, "metadata": {}, "output_type": "execute_result" } ], "source": [ "percent_f = round((female_df["Gender"].count()/players_df["Gender"].count())*100, 2)\n", "percent_f" ] }, { "cell_type": "code", "execution_count": 285, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.89" ] }, "execution_count": 285, "metadata": {}, "output_type": "execute_result" } ], "source": [ "percent_o = round((other_nd_df["Gender"].count()/players_df["Gender"].count())*100, 2)\n", "percent_o" ] }, { "cell_type": "code", "execution_count": 286, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Gender\n", " Percentages\n", " \n", " \n", " \n", " \n", " 0\n", " Male\n", " 82.03\n", " \n", " \n", " 1\n", " Female\n", " 16.08\n", " \n", " \n", " 2\n", " Other / Non-Disclosed\n", " 1.89\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Gender Percentages\n", "0 Male 82.03\n", "1 Female 16.08\n", "2 Other / Non-Disclosed 1.89" ] }, "execution_count": 286, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gender_breakdown_df = pd.DataFrame({\n", " "Gender":["Male", "Female", "Other / Non-Disclosed"],\n", " "Percentages":[percent_m, percent_f, percent_o]\n", "})\n", "gender_breakdown_df" ] }, { "cell_type": "code", "execution_count": 287, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Purchase ID\n", " SN\n", " Age\n", " Gender\n", " Item ID\n", " Item Name\n", " Price\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Iloni35\n", " 20\n", " Male\n", " 93\n", " Apocalyptic Battlescythe\n", " 4.49\n", " \n", " \n", " 1\n", " 1\n", " Aidaira26\n", " 21\n", " Male\n", " 12\n", " Dawne\n", " 3.36\n", " \n", " \n", " 2\n", " 2\n", " Irim47\n", " 17\n", " Male\n", " 5\n", " Putrid Fan\n", " 2.63\n", " \n", " \n", " 3\n", " 3\n", " Irith83\n", " 17\n", " Male\n", " 123\n", " Twilight's Carver\n", " 2.55\n", " \n", " \n", " 4\n", " 4\n", " Philodil43\n", " 22\n", " Male\n", " 154\n", " Feral Katana\n", " 4.11\n", " \n", " \n", " 11\n", " 11\n", " Jiskim75\n", " 36\n", " Female\n", " 173\n", " Stormfury Longsword\n", " 4.01\n", " \n", " \n", " 12\n", " 12\n", " Lirtassa77\n", " 20\n", " Female\n", " 90\n", " Betrayer\n", " 4.12\n", " \n", " \n", " 18\n", " 18\n", " Inadeu25\n", " 12\n", " Other / Non-Disclosed\n", " 176\n", " Relentless Iron Skewer\n", " 2.12\n", " \n", " \n", " 28\n", " 28\n", " Sondassasya91\n", " 20\n", " Female\n", " 170\n", " Shadowsteel\n", " 1.74\n", " \n", " \n", " 32\n", " 32\n", " Alarap40\n", " 24\n", " Female\n", " 117\n", " Heartstriker, Legacy of the Light\n", " 4.71\n", " \n", " \n", " 33\n", " 33\n", " Pharithdil38\n", " 16\n", " Female\n", " 0\n", " Splinter\n", " 1.89\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Purchase ID SN Age Gender Item ID \\n", "0 0 Iloni35 20 Male 93 \n", "1 1 Aidaira26 21 Male 12 \n", "2 2 Irim47 17 Male 5 \n", "3 3 Irith83 17 Male 123 \n", "4 4 Philodil43 22 Male 154 \n", "11 11 Jiskim75 36 Female 173 \n", "12 12 Lirtassa77 20 Female 90 \n", "18 18 Inadeu25 12 Other / Non-Disclosed 176 \n", "28 28 Sondassasya91 20 Female 170 \n", "32 32 Alarap40 24 Female 117 \n", "33 33 Pharithdil38 16 Female 0 \n", "\n", " Item Name Price \n", "0 Apocalyptic Battlescythe 4.49 \n", "1 Dawne 3.36 \n", "2 Putrid Fan 2.63 \n", "3 Twilight's Carver 2.55 \n", "4 Feral Katana 4.11 \n", "11 Stormfury Longsword 4.01 \n", "12 Betrayer 4.12 \n", "18 Relentless Iron Skewer 2.12 \n", "28 Shadowsteel 1.74 \n", "32 Heartstriker, Legacy of the Light 4.71 \n", "33 Splinter 1.89 " ] }, "execution_count": 287, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gender_purchase_group_df = purchase_df.groupby(["Gender"])\n", "gender_purchase_group_df.head()" ] }, { "cell_type": "code", "execution_count": 288, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Gender\n", "Female 13\n", "Male 64\n", "Other / Non-Disclosed 1\n", "Name: Price, dtype: int64" ] }, "execution_count": 288, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gender_ct_series = gender_purchase_group_df["Price"].count()\n", "gender_ct_series" ] }, { "cell_type": "code", "execution_count": 289, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Gender\n", "Female 3.18\n", "Male 2.88\n", "Other / Non-Disclosed 2.12\n", "Name: Price, dtype: float64" ] }, "execution_count": 289, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gender_avg_series = round(gender_purchase_group_df["Price"].mean(), 2)\n", "gender_avg_series" ] }, { "cell_type": "code", "execution_count": 290, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Gender\n", "Female 41.38\n", "Male 184.60\n", "Other / Non-Disclosed 2.12\n", "Name: Price, dtype: float64" ] }, "execution_count": 290, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gender_rev_series = gender_purchase_group_df["Price"].sum()\n", "gender_rev_series" ] }, { "cell_type": "code", "execution_count": 315, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Gender\n", "Female 3.18\n", "Male 2.88\n", "Other / Non-Disclosed 2.12\n", "Name: Price, dtype: float64" ] }, "execution_count": 315, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Normalized Total by Gender\n", "normalized_gender_total = round(gender_rev_series/gender_ct_series, 2)\n", "normalized_gender_total" ] }, { "cell_type": "code", "execution_count": 321, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Count\n", " Percentages\n", " Normalized Totals\n", " Average Purchase Price\n", " Total Revenue\n", " \n", " \n", " Gender\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " Female\n", " 13\n", " 16.08\n", " 3.18\n", " 3.18\n", " 41.38\n", " \n", " \n", " Male\n", " 64\n", " 82.03\n", " 2.88\n", " 2.88\n", " 184.60\n", " \n", " \n", " Other / Non-Disclosed\n", " 1\n", " 1.89\n", " 2.12\n", " 2.12\n", " 2.12\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Count Percentages Normalized Totals \\n", "Gender \n", "Female 13 16.08 3.18 \n", "Male 64 82.03 2.88 \n", "Other / Non-Disclosed 1 1.89 2.12 \n", "\n", " Average Purchase Price Total Revenue \n", "Gender \n", "Female 3.18 41.38 \n", "Male 2.88 184.60 \n", "Other / Non-Disclosed 2.12 2.12 " ] }, "execution_count": 321, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Combining series into dataframes by using dictionaries\n", "gender_analysis_df = pd.DataFrame({"Count": gender_ct_series,\n", " "Percentages": [percent_f, percent_m, percent_o],\n", " "Normalized Totals": normalized_gender_total,\n", " "Average Purchase Price": gender_avg_series, \n", " "Total Revenue":gender_rev_series})\n", "gender_analysis_df" ] }, { "cell_type": "code", "execution_count": 293, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "40" ] }, "execution_count": 293, "metadata": {}, "output_type": "execute_result" } ], "source": [ "max_age = purchase_df["Age"].max()\n", "max_age" ] }, { "cell_type": "code", "execution_count": 294, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "7" ] }, "execution_count": 294, "metadata": {}, "output_type": "execute_result" } ], "source": [ "min_age = purchase_df["Age"].min()\n", "min_age" ] }, { "cell_type": "code", "execution_count": 317, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 20-24\n", "1 20-24\n", "2 15-19\n", "3 15-19\n", "4 20-24\n", "5 0-10\n", "6 40+\n", "7 25-29\n", "8 15-19\n", "9 35-39\n", "10 20-24\n", "11 35-39\n", "12 20-24\n", "13 30-34\n", "14 0-10\n", "15 20-24\n", "16 20-24\n", "17 0-10\n", "18 10-14\n", "19 20-24\n", "20 35-39\n", "21 10-14\n", "22 15-19\n", "23 20-24\n", "24 20-24\n", "25 15-19\n", "26 0-10\n", "27 25-29\n", "28 20-24\n", "29 20-24\n", " ... \n", "48 25-29\n", "49 20-24\n", "50 20-24\n", "51 25-29\n", "52 20-24\n", "53 15-19\n", "54 25-29\n", "55 20-24\n", "56 15-19\n", "57 20-24\n", "58 30-34\n", "59 35-39\n", "60 20-24\n", "61 20-24\n", "62 15-19\n", "63 10-14\n", "64 20-24\n", "65 20-24\n", "66 20-24\n", "67 20-24\n", "68 20-24\n", "69 30-34\n", "70 25-29\n", "71 25-29\n", "72 20-24\n", "73 35-39\n", "74 35-39\n", "75 15-19\n", "76 20-24\n", "77 20-24\n", "Name: Age, Length: 78, dtype: category\n", "Categories (8, object): [0-10 < 10-14 < 15-19 < 20-24 < 25-29 < 30-34 < 35-39 < 40+]" ] }, "execution_count": 317, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create the bins in which Age Data will be held\n", "bins = [0, 9, 14, 19, 24, 29, 34, 39, 44]\n", "\n", "# Create the names for the eight bins\n", "group_names = ["0-10", "10-14", "15-19", "20-24", "25-29", "30-34", "35-39", "40+"]\n", "\n", "age_bins = pd.cut(purchase_df["Age"], bins, labels=group_names)\n", "age_bins" ] }, { "cell_type": "code", "execution_count": 297, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Purchase ID\n", " SN\n", " Age\n", " Gender\n", " Item ID\n", " Item Name\n", " Price\n", " Age Bins\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Iloni35\n", " 20\n", " Male\n", " 93\n", " Apocalyptic Battlescythe\n", " 4.49\n", " 20-24\n", " \n", " \n", " 1\n", " 1\n", " Aidaira26\n", " 21\n", " Male\n", " 12\n", " Dawne\n", " 3.36\n", " 20-24\n", " \n", " \n", " 2\n", " 2\n", " Irim47\n", " 17\n", " Male\n", " 5\n", " Putrid Fan\n", " 2.63\n", " 15-19\n", " \n", " \n", " 3\n", " 3\n", " Irith83\n", " 17\n", " Male\n", " 123\n", " Twilight's Carver\n", " 2.55\n", " 15-19\n", " \n", " \n", " 4\n", " 4\n", " Philodil43\n", " 22\n", " Male\n", " 154\n", " Feral Katana\n", " 4.11\n", " 20-24\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Purchase ID SN Age Gender Item ID Item Name \\n", "0 0 Iloni35 20 Male 93 Apocalyptic Battlescythe \n", "1 1 Aidaira26 21 Male 12 Dawne \n", "2 2 Irim47 17 Male 5 Putrid Fan \n", "3 3 Irith83 17 Male 123 Twilight's Carver \n", "4 4 Philodil43 22 Male 154 Feral Katana \n", "\n", " Price Age Bins \n", "0 4.49 20-24 \n", "1 3.36 20-24 \n", "2 2.63 15-19 \n", "3 2.55 15-19 \n", "4 4.11 20-24 " ] }, "execution_count": 297, "metadata": {}, "output_type": "execute_result" } ], "source": [ "purchase_df["Age Bins"] = pd.cut(\n", " purchase_df["Age"], bins, labels=group_names)\n", "purchase_df.head()" ] }, { "cell_type": "code", "execution_count": 298, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Purchase ID\n", " SN\n", " Age\n", " Gender\n", " Item ID\n", " Item Name\n", " Price\n", " Age Bins\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Iloni35\n", " 20\n", " Male\n", " 93\n", " Apocalyptic Battlescythe\n", " 4.49\n", " 20-24\n", " \n", " \n", " 1\n", " 1\n", " Aidaira26\n", " 21\n", " Male\n", " 12\n", " Dawne\n", " 3.36\n", " 20-24\n", " \n", " \n", " 2\n", " 2\n", " Irim47\n", " 17\n", " Male\n", " 5\n", " Putrid Fan\n", " 2.63\n", " 15-19\n", " \n", " \n", " 3\n", " 3\n", " Irith83\n", " 17\n", " Male\n", " 123\n", " Twilight's Carver\n", " 2.55\n", " 15-19\n", " \n", " \n", " 4\n", " 4\n", " Philodil43\n", " 22\n", " Male\n", " 154\n", " Feral Katana\n", " 4.11\n", " 20-24\n", " \n", " \n", " 5\n", " 5\n", " Hainaria90\n", " 8\n", " Male\n", " 8\n", " Purgatory, Gem of Regret\n", " 2.22\n", " 0-10\n", " \n", " \n", " 6\n", " 6\n", " Aerithllora36\n", " 40\n", " Male\n", " 148\n", " Warmonger, Gift of Suffering's End\n", " 4.65\n", " 40+\n", " \n", " \n", " 7\n", " 7\n", " Undirra90\n", " 28\n", " Male\n", " 27\n", " Riddle, Tribute of Ended Dreams\n", " 3.38\n", " 25-29\n", " \n", " \n", " 8\n", " 8\n", " Eolideu96\n", " 18\n", " Male\n", " 111\n", " Misery's End\n", " 1.79\n", " 15-19\n", " \n", " \n", " 9\n", " 9\n", " Aesurstilis64\n", " 36\n", " Male\n", " 139\n", " Mercy, Katana of Dismay\n", " 4.25\n", " 35-39\n", " \n", " \n", " 10\n", " 10\n", " Jiskimsda56\n", " 24\n", " Male\n", " 126\n", " Exiled Mithril Longsword\n", " 1.08\n", " 20-24\n", " \n", " \n", " 11\n", " 11\n", " Jiskim75\n", " 36\n", " Female\n", " 173\n", " Stormfury Longsword\n", " 4.01\n", " 35-39\n", " \n", " \n", " 12\n", " 12\n", " Lirtassa77\n", " 20\n", " Female\n", " 90\n", " Betrayer\n", " 4.12\n", " 20-24\n", " \n", " \n", " 13\n", " 13\n", " Hairith93\n", " 32\n", " Male\n", " 23\n", " Crucifer\n", " 1.62\n", " 30-34\n", " \n", " \n", " 14\n", " 14\n", " Yarith71\n", " 8\n", " Male\n", " 44\n", " Bonecarvin Battle Axe\n", " 4.36\n", " 0-10\n", " \n", " \n", " 17\n", " 17\n", " Rarallo90\n", " 9\n", " Male\n", " 156\n", " Soul-Forged Steel Shortsword\n", " 4.53\n", " 0-10\n", " \n", " \n", " 18\n", " 18\n", " Inadeu25\n", " 12\n", " Other / Non-Disclosed\n", " 176\n", " Relentless Iron Skewer\n", " 2.12\n", " 10-14\n", " \n", " \n", " 20\n", " 20\n", " Streural92\n", " 35\n", " Male\n", " 10\n", " Sleepwalker\n", " 1.81\n", " 35-39\n", " \n", " \n", " 21\n", " 21\n", " Eoralphos86\n", " 11\n", " Male\n", " 131\n", " Fury\n", " 2.99\n", " 10-14\n", " \n", " \n", " 22\n", " 22\n", " Shaidanu32\n", " 16\n", " Male\n", " 172\n", " Blade of the Grave\n", " 2.71\n", " 15-19\n", " \n", " \n", " 25\n", " 25\n", " Ilara98\n", " 17\n", " Male\n", " 71\n", " Demise\n", " 3.09\n", " 15-19\n", " \n", " \n", " 26\n", " 26\n", " Lirtistanya48\n", " 7\n", " Male\n", " 98\n", " Deadline, Voice Of Subtlety\n", " 1.29\n", " 0-10\n", " \n", " \n", " 27\n", " 27\n", " Sundaky74\n", " 25\n", " Male\n", " 117\n", " Heartstriker, Legacy of the Light\n", " 4.71\n", " 25-29\n", " \n", " \n", " 30\n", " 30\n", " Hairith93\n", " 32\n", " Male\n", " 138\n", " Peacekeeper, Wit of Dark Magic\n", " 2.63\n", " 30-34\n", " \n", " \n", " 31\n", " 31\n", " Ethralan59\n", " 33\n", " Male\n", " 129\n", " Fate, Vengeance of Eternal Justice\n", " 2.88\n", " 30-34\n", " \n", " \n", " 37\n", " 37\n", " Chanjasksda31\n", " 33\n", " Male\n", " 17\n", " Lazarus, Terror of the Earth\n", " 1.96\n", " 30-34\n", " \n", " \n", " 38\n", " 38\n", " Aiduecal76\n", " 8\n", " Male\n", " 9\n", " Thorn, Conqueror of the Corrupted\n", " 1.42\n", " 0-10\n", " \n", " \n", " 41\n", " 41\n", " Lirtastan49\n", " 25\n", " Male\n", " 127\n", " Heartseeker, Reaver of Souls\n", " 1.34\n", " 25-29\n", " \n", " \n", " 44\n", " 44\n", " Saralp86\n", " 25\n", " Male\n", " 64\n", " Fusion Pummel\n", " 2.42\n", " 25-29\n", " \n", " \n", " 47\n", " 47\n", " Eustyria89\n", " 30\n", " Male\n", " 60\n", " Wolf\n", " 2.70\n", " 30-34\n", " \n", " \n", " 48\n", " 48\n", " Eusty71\n", " 25\n", " Male\n", " 84\n", " Arcane Gem\n", " 4.81\n", " 25-29\n", " \n", " \n", " 59\n", " 59\n", " Aesririam61\n", " 39\n", " Female\n", " 2\n", " Verdict\n", " 2.65\n", " 35-39\n", " \n", " \n", " 63\n", " 63\n", " Isristira52\n", " 11\n", " Female\n", " 41\n", " Orbit\n", " 3.85\n", " 10-14\n", " \n", " \n", " 73\n", " 73\n", " Chamast86\n", " 35\n", " Male\n", " 93\n", " Apocalyptic Battlescythe\n", " 4.49\n", " 35-39\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Purchase ID SN Age Gender Item ID \\n", "0 0 Iloni35 20 Male 93 \n", "1 1 Aidaira26 21 Male 12 \n", "2 2 Irim47 17 Male 5 \n", "3 3 Irith83 17 Male 123 \n", "4 4 Philodil43 22 Male 154 \n", "5 5 Hainaria90 8 Male 8 \n", "6 6 Aerithllora36 40 Male 148 \n", "7 7 Undirra90 28 Male 27 \n", "8 8 Eolideu96 18 Male 111 \n", "9 9 Aesurstilis64 36 Male 139 \n", "10 10 Jiskimsda56 24 Male 126 \n", "11 11 Jiskim75 36 Female 173 \n", "12 12 Lirtassa77 20 Female 90 \n", "13 13 Hairith93 32 Male 23 \n", "14 14 Yarith71 8 Male 44 \n", "17 17 Rarallo90 9 Male 156 \n", "18 18 Inadeu25 12 Other / Non-Disclosed 176 \n", "20 20 Streural92 35 Male 10 \n", "21 21 Eoralphos86 11 Male 131 \n", "22 22 Shaidanu32 16 Male 172 \n", "25 25 Ilara98 17 Male 71 \n", "26 26 Lirtistanya48 7 Male 98 \n", "27 27 Sundaky74 25 Male 117 \n", "30 30 Hairith93 32 Male 138 \n", "31 31 Ethralan59 33 Male 129 \n", "37 37 Chanjasksda31 33 Male 17 \n", "38 38 Aiduecal76 8 Male 9 \n", "41 41 Lirtastan49 25 Male 127 \n", "44 44 Saralp86 25 Male 64 \n", "47 47 Eustyria89 30 Male 60 \n", "48 48 Eusty71 25 Male 84 \n", "59 59 Aesririam61 39 Female 2 \n", "63 63 Isristira52 11 Female 41 \n", "73 73 Chamast86 35 Male 93 \n", "\n", " Item Name Price Age Bins \n", "0 Apocalyptic Battlescythe 4.49 20-24 \n", "1 Dawne 3.36 20-24 \n", "2 Putrid Fan 2.63 15-19 \n", "3 Twilight's Carver 2.55 15-19 \n", "4 Feral Katana 4.11 20-24 \n", "5 Purgatory, Gem of Regret 2.22 0-10 \n", "6 Warmonger, Gift of Suffering's End 4.65 40+ \n", "7 Riddle, Tribute of Ended Dreams 3.38 25-29 \n", "8 Misery's End 1.79 15-19 \n", "9 Mercy, Katana of Dismay 4.25 35-39 \n", "10 Exiled Mithril Longsword 1.08 20-24 \n", "11 Stormfury Longsword 4.01 35-39 \n", "12 Betrayer 4.12 20-24 \n", "13 Crucifer 1.62 30-34 \n", "14 Bonecarvin Battle Axe 4.36 0-10 \n", "17 Soul-Forged Steel Shortsword 4.53 0-10 \n", "18 Relentless Iron Skewer 2.12 10-14 \n", "20 Sleepwalker 1.81 35-39 \n", "21 Fury 2.99 10-14 \n", "22 Blade of the Grave 2.71 15-19 \n", "25 Demise 3.09 15-19 \n", "26 Deadline, Voice Of Subtlety 1.29 0-10 \n", "27 Heartstriker, Legacy of the Light 4.71 25-29 \n", "30 Peacekeeper, Wit of Dark Magic 2.63 30-34 \n", "31 Fate, Vengeance of Eternal Justice 2.88 30-34 \n", "37 Lazarus, Terror of the Earth 1.96 30-34 \n", "38 Thorn, Conqueror of the Corrupted 1.42 0-10 \n", "41 Heartseeker, Reaver of Souls 1.34 25-29 \n", "44 Fusion Pummel 2.42 25-29 \n", "47 Wolf 2.70 30-34 \n", "48 Arcane Gem 4.81 25-29 \n", "59 Verdict 2.65 35-39 \n", "63 Orbit 3.85 10-14 \n", "73 Apocalyptic Battlescythe 4.49 35-39 " ] }, "execution_count": 298, "metadata": {}, "output_type": "execute_result" } ], "source": [ "age_purchase_group_df = purchase_df.groupby(["Age Bins"])\n", "age_purchase_group_df.head()" ] }, { "cell_type": "code", "execution_count": 299, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Age Bins\n", "0-10 5\n", "10-14 3\n", "15-19 11\n", "20-24 36\n", "25-29 9\n", "30-34 7\n", "35-39 6\n", "40+ 1\n", "Name: Price, dtype: int64" ] }, "execution_count": 299, "metadata": {}, "output_type": "execute_result" } ], "source": [ "age_ct_series = age_purchase_group_df["Price"].count()\n", "age_ct_series" ] }, { "cell_type": "code", "execution_count": 300, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Age Bins\n", "0-10 2.76\n", "10-14 2.99\n", "15-19 2.76\n", "20-24 3.02\n", "25-29 2.90\n", "30-34 1.98\n", "35-39 3.56\n", "40+ 4.65\n", "Name: Price, dtype: float64" ] }, "execution_count": 300, "metadata": {}, "output_type": "execute_result" } ], "source": [ "age_avg_series = round(age_purchase_group_df["Price"].mean(), 2)\n", "age_avg_series" ] }, { "cell_type": "code", "execution_count": 301, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Age Bins\n", "0-10 13.82\n", "10-14 8.96\n", "15-19 30.41\n", "20-24 108.89\n", "25-29 26.11\n", "30-34 13.89\n", "35-39 21.37\n", "40+ 4.65\n", "Name: Price, dtype: float64" ] }, "execution_count": 301, "metadata": {}, "output_type": "execute_result" } ], "source": [ "age_rev_series = round(age_purchase_group_df["Price"].sum(), 2)\n", "age_rev_series" ] }, { "cell_type": "code", "execution_count": 313, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Age Bins\n", "0-10 2.76\n", "10-14 2.99\n", "15-19 2.76\n", "20-24 3.02\n", "25-29 2.90\n", "30-34 1.98\n", "35-39 3.56\n", "40+ 4.65\n", "Name: Price, dtype: float64" ] }, "execution_count": 313, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Normalized Total by Age\n", "normalized_age_total = round(age_rev_series/age_ct_series, 2)\n", "normalized_age_total" ] }, { "cell_type": "code", "execution_count": 314, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Count\n", " Normalized Totals\n", " Average Purchase Price\n", " Total Revenue\n", " \n", " \n", " Age Bins\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " 0-10\n", " 5\n", " 2.76\n", " 2.76\n", " 13.82\n", " \n", " \n", " 10-14\n", " 3\n", " 2.99\n", " 2.99\n", " 8.96\n", " \n", " \n", " 15-19\n", " 11\n", " 2.76\n", " 2.76\n", " 30.41\n", " \n", " \n", " 20-24\n", " 36\n", " 3.02\n", " 3.02\n", " 108.89\n", " \n", " \n", " 25-29\n", " 9\n", " 2.90\n", " 2.90\n", " 26.11\n", " \n", " \n", " 30-34\n", " 7\n", " 1.98\n", " 1.98\n", " 13.89\n", " \n", " \n", " 35-39\n", " 6\n", " 3.56\n", " 3.56\n", " 21.37\n", " \n", " \n", " 40+\n", " 1\n", " 4.65\n", " 4.65\n", " 4.65\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Count Normalized Totals Average Purchase Price Total Revenue\n", "Age Bins \n", "0-10 5 2.76 2.76 13.82\n", "10-14 3 2.99 2.99 8.96\n", "15-19 11 2.76 2.76 30.41\n", "20-24 36 3.02 3.02 108.89\n", "25-29 9 2.90 2.90 26.11\n", "30-34 7 1.98 1.98 13.89\n", "35-39 6 3.56 3.56 21.37\n", "40+ 1 4.65 4.65 4.65" ] }, "execution_count": 314, "metadata": {}, "output_type": "execute_result" } ], "source": [ "age_df = pd.DataFrame({\n", " "Count": age_ct_series,\n", " "Normalized Totals": normalized_age_total,\n", " "Average Purchase Price": age_avg_series, \n", " "Total Revenue":age_rev_series})\n", "age_df" ] }, { "cell_type": "code", "execution_count": 304, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "48 4.81\n", "62 4.78\n", "27 4.71\n", "32 4.71\n", "6 4.65\n", "61 4.59\n", "17 4.53\n", "0 4.49\n", "73 4.49\n", "60 4.39\n", "14 4.36\n", "24 4.28\n", "9 4.25\n", "74 4.16\n", "57 4.15\n", "65 4.12\n", "29 4.12\n", "12 4.12\n", "4 4.11\n", "19 4.11\n", "39 4.04\n", "11 4.01\n", "63 3.85\n", "40 3.75\n", "51 3.67\n", "53 3.64\n", "67 3.64\n", "15 3.64\n", "46 3.58\n", "7 3.38\n", " ... \n", "44 2.42\n", "55 2.26\n", "36 2.26\n", "5 2.22\n", "77 2.15\n", "43 2.15\n", "18 2.12\n", "50 2.12\n", "37 1.96\n", "23 1.94\n", "76 1.92\n", "66 1.91\n", "33 1.89\n", "35 1.84\n", "20 1.81\n", "54 1.79\n", "8 1.79\n", "68 1.77\n", "28 1.74\n", "13 1.62\n", "38 1.42\n", "16 1.36\n", "41 1.34\n", "56 1.31\n", "64 1.31\n", "70 1.29\n", "26 1.29\n", "10 1.08\n", "69 1.08\n", "58 1.02\n", "Name: Price, Length: 78, dtype: float64" ] }, "execution_count": 304, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rank_spenders = purchase_df["Price"].sort_values(ascending=False)\n", "rank_spenders" ] }, { "cell_type": "code", "execution_count": 305, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Purchase ID\n", " SN\n", " Age\n", " Gender\n", " Item ID\n", " Item Name\n", " Price\n", " Age Bins\n", " Spending Rank\n", " \n", " \n", " \n", " \n", " 0\n", " 0\n", " Iloni35\n", " 20\n", " Male\n", " 93\n", " Apocalyptic Battlescythe\n", " 4.49\n", " 20-24\n", " 4.49\n", " \n", " \n", " 1\n", " 1\n", " Aidaira26\n", " 21\n", " Male\n", " 12\n", " Dawne\n", " 3.36\n", " 20-24\n", " 3.36\n", " \n", " \n", " 2\n", " 2\n", " Irim47\n", " 17\n", " Male\n", " 5\n", " Putrid Fan\n", " 2.63\n", " 15-19\n", " 2.63\n", " \n", " \n", " 3\n", " 3\n", " Irith83\n", " 17\n", " Male\n", " 123\n", " Twilight's Carver\n", " 2.55\n", " 15-19\n", " 2.55\n", " \n", " \n", " 4\n", " 4\n", " Philodil43\n", " 22\n", " Male\n", " 154\n", " Feral Katana\n", " 4.11\n", " 20-24\n", " 4.11\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Purchase ID SN Age Gender Item ID Item Name \\n", "0 0 Iloni35 20 Male 93 Apocalyptic Battlescythe \n", "1 1 Aidaira26 21 Male 12 Dawne \n", "2 2 Irim47 17 Male 5 Putrid Fan \n", "3 3 Irith83 17 Male 123 Twilight's Carver \n", "4 4 Philodil43 22 Male 154 Feral Katana \n", "\n", " Price Age Bins Spending Rank \n", "0 4.49 20-24 4.49 \n", "1 3.36 20-24 3.36 \n", "2 2.63 15-19 2.63 \n", "3 2.55 15-19 2.55 \n", "4 4.11 20-24 4.11 " ] }, "execution_count": 305, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Do groupby descending values or\n", "\n", "purchase_df["Spending Rank"] = purchase_df["Price"].sort_values(ascending=False)\n", "purchase_df.head()" ] }, { "cell_type": "code", "execution_count": 306, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " SN\n", " Spending Rank\n", " \n", " \n", " \n", " \n", " 48\n", " Eusty71\n", " 4.81\n", " \n", " \n", " 62\n", " Chanirra64\n", " 4.78\n", " \n", " \n", " 27\n", " Sundaky74\n", " 4.71\n", " \n", " \n", " 32\n", " Alarap40\n", " 4.71\n", " \n", " \n", " 6\n", " Aerithllora36\n", " 4.65\n", " \n", " \n", " 61\n", " Jiskjask76\n", " 4.59\n", " \n", " \n", "\n", "
" ], "text/plain": [ " SN Spending Rank\n", "48 Eusty71 4.81\n", "62 Chanirra64 4.78\n", "27 Sundaky74 4.71\n", "32 Alarap40 4.71\n", "6 Aerithllora36 4.65\n", "61 Jiskjask76 4.59" ] }, "execution_count": 306, "metadata": {}, "output_type": "execute_result" } ], "source": [ "purchase_rank_df_a = purchase_df.sort_values(by = "Spending Rank", ascending=False)\n", "purchase_rank_df_b = purchase_rank_df_a[["SN", "Spending Rank"]]\n", "purchase_rank_df_b.head(6)" ] }, { "cell_type": "code", "execution_count": 318, "metadata": {}, "outputs": [], "source": [ "top_spend_ct = purchase_rank_df_b.head()["Spending Rank"].count()\n", "top_spend_avg = round(purchase_rank_df_b.head()["Spending Rank"].mean(), 2)\n", "top_spend_tot = purchase_rank_df_b.head()["Spending Rank"].sum()" ] }, { "cell_type": "code", "execution_count": 319, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Number of Top Spenders\n", " Average Purchase Price of Top 5 Spenders\n", " Total Revenue of Top 5 Spenders\n", " \n", " \n", " \n", " \n", " 0\n", " 5\n", " 4.73\n", " 23.66\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Number of Top Spenders Average Purchase Price of Top 5 Spenders \\n", "0 5 4.73 \n", "\n", " Total Revenue of Top 5 Spenders \n", "0 23.66 " ] }, "execution_count": 319, "metadata": {}, "output_type": "execute_result" } ], "source": [ "summary_top5_df = pd.DataFrame({\n", " "Number of Top Spenders":[top_spend_ct],\n", " "Average Purchase Price of Top 5 Spenders":[top_spend_avg],\n", " "Total Revenue of Top 5 Spenders":[top_spend_tot]\n", "})\n", "summary_top5_df" ] }, { "cell_type": "code", "execution_count": 320, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Item Name\n", " Item ID\n", " Price\n", " Gender\n", " \n", " \n", " \n", " \n", " 0\n", " Apocalyptic Battlescythe\n", " 93\n", " 4.49\n", " Male\n", " \n", " \n", " 1\n", " Dawne\n", " 12\n", " 3.36\n", " Male\n", " \n", " \n", " 2\n", " Putrid Fan\n", " 5\n", " 2.63\n", " Male\n", " \n", " \n", " 3\n", " Twilight's Carver\n", " 123\n", " 2.55\n", " Male\n", " \n", " \n", " 4\n", " Feral Katana\n", " 154\n", " 4.11\n", " Male\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Item Name Item ID Price Gender\n", "0 Apocalyptic Battlescythe 93 4.49 Male\n", "1 Dawne 12 3.36 Male\n", "2 Putrid Fan 5 2.63 Male\n", "3 Twilight's Carver 123 2.55 Male\n", "4 Feral Katana 154 4.11 Male" ] }, "execution_count": 320, "metadata": {}, "output_type": "execute_result" } ], "source": [ "item_purchase_group = purchase_df.loc[:,["Item Name", "Item ID", "Price", "Gender"]]\n", "item_purchase_group.head()" ] }, { "cell_type": "code", "execution_count": 310, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Item ID\n", " Price\n", " Popularity Count\n", " Total Purchase Value\n", " \n", " \n", " Item Name\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " Mourning Blade\n", " 94\n", " 3.64\n", " 3\n", " 10.92\n", " \n", " \n", " Betrayer\n", " 90\n", " 4.12\n", " 2\n", " 8.24\n", " \n", " \n", " Misery's End\n", " 111\n", " 1.79\n", " 2\n", " 3.58\n", " \n", " \n", " Fusion Pummel\n", " 64\n", " 2.42\n", " 2\n", " 4.84\n", " \n", " \n", " Feral Katana\n", " 154\n", " 4.11\n", " 2\n", " 8.22\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Item ID Price Popularity Count Total Purchase Value\n", "Item Name \n", "Mourning Blade 94 3.64 3 10.92\n", "Betrayer 90 4.12 2 8.24\n", "Misery's End 111 1.79 2 3.58\n", "Fusion Pummel 64 2.42 2 4.84\n", "Feral Katana 154 4.11 2 8.22" ] }, "execution_count": 310, "metadata": {}, "output_type": "execute_result" } ], "source": [ "total_item_purchase = item_purchase_group.groupby(["Item ID", "Item Name", "Price"]).count()\n", "total_item_purchase = total_item_purchase.rename(columns={"Gender":"Popularity Count"})\n", "total_item_purchase = total_item_purchase.sort_values(by="Popularity Count", ascending=False)\n", "total_item_purchase = total_item_purchase.reset_index(level=["Item ID", "Price"])\n", "total_item_purchase["Total Purchase Value"] = total_item_purchase["Price"]*total_item_purchase["Popularity Count"]\n", "total_item_purchase.head()" ] }, { "cell_type": "code", "execution_count": 311, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Item Name\n", " Item ID\n", " Price\n", " Gender\n", " \n", " \n", " \n", " \n", " 0\n", " Apocalyptic Battlescythe\n", " 93\n", " 4.49\n", " Male\n", " \n", " \n", " 1\n", " Dawne\n", " 12\n", " 3.36\n", " Male\n", " \n", " \n", " 2\n", " Putrid Fan\n", " 5\n", " 2.63\n", " Male\n", " \n", " \n", " 3\n", " Twilight's Carver\n", " 123\n", " 2.55\n", " Male\n", " \n", " \n", " 4\n", " Feral Katana\n", " 154\n", " 4.11\n", " Male\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Item Name Item ID Price Gender\n", "0 Apocalyptic Battlescythe 93 4.49 Male\n", "1 Dawne 12 3.36 Male\n", "2 Putrid Fan 5 2.63 Male\n", "3 Twilight's Carver 123 2.55 Male\n", "4 Feral Katana 154 4.11 Male" ] }, "execution_count": 311, "metadata": {}, "output_type": "execute_result" } ], "source": [ "item_profit_group = purchase_df.loc[:,["Item Name", "Item ID", "Price", "Gender"]]\n", "item_profit_group.head()" ] }, { "cell_type": "code", "execution_count": 312, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<style scoped>\n", " .dataframe tbody tr th:only-of-type {\n", " vertical-align: middle;\n", " }\n", "\n", " .dataframe tbody tr th {\n", " vertical-align: top;\n", " }\n", "\n", " .dataframe thead th {\n", " text-align: right;\n", " }\n", "</style>\n", "<table border="1" class="dataframe">\n", " \n", " <tr style="text-align: right;">\n", " \n", " Item ID\n", " Price\n", " Purchase Count\n", " Total Purchase Value\n", " \n", " \n", " Item Name\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " Arcane Gem\n", " 84\n", " 4.81\n", " 1\n", " 4.81\n", " \n", " \n", " Hero Cane\n", " 25\n", " 4.78\n", " 1\n", " 4.78\n", " \n", " \n", " Heartstriker, Legacy of the Light\n", " 117\n", " 4.71\n", " 2\n", " 9.42\n", " \n", " \n", " Warmonger, Gift of Suffering's End\n", " 148\n", " 4.65\n", " 1\n", " 4.65\n", " \n", " \n", " Trickster\n", " 31\n", " 4.59\n", " 1\n", " 4.59\n", " \n", " \n", "\n", "
" ], "text/plain": [ " Item ID Price Purchase Count \\n", "Item Name \n", "Arcane Gem 84 4.81 1 \n", "Hero Cane 25 4.78 1 \n", "Heartstriker, Legacy of the Light 117 4.71 2 \n", "Warmonger, Gift of Suffering's End 148 4.65 1 \n", "Trickster 31 4.59 1 \n", "\n", " Total Purchase Value \n", "Item Name \n", "Arcane Gem 4.81 \n", "Hero Cane 4.78 \n", "Heartstriker, Legacy of the Light 9.42 \n", "Warmonger, Gift of Suffering's End 4.65 \n", "Trickster 4.59 " ] }, "execution_count": 312, "metadata": {}, "output_type": "execute_result" } ], "source": [ "total_item_profit = item_profit_group.groupby(["Item ID", "Item Name", "Price"]).count()\n", "total_item_profit = total_item_profit.rename(columns={"Gender":"Purchase Count"})\n", "total_item_profit = total_item_profit.sort_values(by="Price", ascending=False)\n", "total_item_profit = total_item_profit.reset_index(level=["Item ID", "Price"])\n", "total_item_profit["Total Purchase Value"] = total_item_profit["Price"]*total_item_profit["Purchase Count"]\n", "total_item_profit.head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published