This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

Commit 6c5d2971 authored by henrycwong's avatar henrycwong

add cleaned team data

parent 2cd4102b
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_excel(\"2018springLCSteams.xlsx\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\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",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>gameid</th>\n",
" <th>url</th>\n",
" <th>league</th>\n",
" <th>split</th>\n",
" <th>date</th>\n",
" <th>week</th>\n",
" <th>game</th>\n",
" <th>patchno</th>\n",
" <th>playerid</th>\n",
" <th>side</th>\n",
" <th>...</th>\n",
" <th>gdat15</th>\n",
" <th>xpat10</th>\n",
" <th>oppxpat10</th>\n",
" <th>xpdat10</th>\n",
" <th>csat10</th>\n",
" <th>oppcsat10</th>\n",
" <th>csdat10</th>\n",
" <th>csat15</th>\n",
" <th>oppcsat15</th>\n",
" <th>csdat15</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1002440062</td>\n",
" <td>https://matchhistory.na.leagueoflegends.com/en...</td>\n",
" <td>NALCS</td>\n",
" <td>2018-1</td>\n",
" <td>43120.659838</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8.01</td>\n",
" <td>100</td>\n",
" <td>Blue</td>\n",
" <td>...</td>\n",
" <td>2387</td>\n",
" <td>18541</td>\n",
" <td>18703</td>\n",
" <td>-162</td>\n",
" <td>341</td>\n",
" <td>374</td>\n",
" <td>-33</td>\n",
" <td>551</td>\n",
" <td>599</td>\n",
" <td>-48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1002440062</td>\n",
" <td>https://matchhistory.na.leagueoflegends.com/en...</td>\n",
" <td>NALCS</td>\n",
" <td>2018-1</td>\n",
" <td>43120.659838</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8.01</td>\n",
" <td>200</td>\n",
" <td>Red</td>\n",
" <td>...</td>\n",
" <td>-2387</td>\n",
" <td>18703</td>\n",
" <td>18541</td>\n",
" <td>162</td>\n",
" <td>374</td>\n",
" <td>341</td>\n",
" <td>33</td>\n",
" <td>599</td>\n",
" <td>551</td>\n",
" <td>48</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1002440076</td>\n",
" <td>https://matchhistory.na.leagueoflegends.com/en...</td>\n",
" <td>NALCS</td>\n",
" <td>2018-1</td>\n",
" <td>43120.734965</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8.01</td>\n",
" <td>100</td>\n",
" <td>Blue</td>\n",
" <td>...</td>\n",
" <td>-1609</td>\n",
" <td>19223</td>\n",
" <td>19671</td>\n",
" <td>-448</td>\n",
" <td>344</td>\n",
" <td>351</td>\n",
" <td>-7</td>\n",
" <td>560</td>\n",
" <td>564</td>\n",
" <td>-4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1002440076</td>\n",
" <td>https://matchhistory.na.leagueoflegends.com/en...</td>\n",
" <td>NALCS</td>\n",
" <td>2018-1</td>\n",
" <td>43120.734965</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8.01</td>\n",
" <td>200</td>\n",
" <td>Red</td>\n",
" <td>...</td>\n",
" <td>1609</td>\n",
" <td>19671</td>\n",
" <td>19223</td>\n",
" <td>448</td>\n",
" <td>351</td>\n",
" <td>344</td>\n",
" <td>7</td>\n",
" <td>564</td>\n",
" <td>560</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1002440084</td>\n",
" <td>https://matchhistory.na.leagueoflegends.com/en...</td>\n",
" <td>NALCS</td>\n",
" <td>2018-1</td>\n",
" <td>43120.801632</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>8.01</td>\n",
" <td>100</td>\n",
" <td>Blue</td>\n",
" <td>...</td>\n",
" <td>836</td>\n",
" <td>19785</td>\n",
" <td>18502</td>\n",
" <td>1283</td>\n",
" <td>352</td>\n",
" <td>354</td>\n",
" <td>-2</td>\n",
" <td>557</td>\n",
" <td>569</td>\n",
" <td>-12</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 98 columns</p>\n",
"</div>"
],
"text/plain": [
" gameid url league \\\n",
"0 1002440062 https://matchhistory.na.leagueoflegends.com/en... NALCS \n",
"1 1002440062 https://matchhistory.na.leagueoflegends.com/en... NALCS \n",
"2 1002440076 https://matchhistory.na.leagueoflegends.com/en... NALCS \n",
"3 1002440076 https://matchhistory.na.leagueoflegends.com/en... NALCS \n",
"4 1002440084 https://matchhistory.na.leagueoflegends.com/en... NALCS \n",
"\n",
" split date week game patchno playerid side ... gdat15 xpat10 \\\n",
"0 2018-1 43120.659838 1 1 8.01 100 Blue ... 2387 18541 \n",
"1 2018-1 43120.659838 1 1 8.01 200 Red ... -2387 18703 \n",
"2 2018-1 43120.734965 1 1 8.01 100 Blue ... -1609 19223 \n",
"3 2018-1 43120.734965 1 1 8.01 200 Red ... 1609 19671 \n",
"4 2018-1 43120.801632 1 1 8.01 100 Blue ... 836 19785 \n",
"\n",
" oppxpat10 xpdat10 csat10 oppcsat10 csdat10 csat15 oppcsat15 csdat15 \n",
"0 18703 -162 341 374 -33 551 599 -48 \n",
"1 18541 162 374 341 33 599 551 48 \n",
"2 19671 -448 344 351 -7 560 564 -4 \n",
"3 19223 448 351 344 7 564 560 4 \n",
"4 18502 1283 352 354 -2 557 569 -12 \n",
"\n",
"[5 rows x 98 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df.index,\"doubles\"] = df[\"doubles\"].replace(' ',0)\n",
"df.loc[df.index,\"doubles\"] = df[\"doubles\"].astype(int)\n",
"df.loc[df.index,\"triples\"] = df[\"triples\"].replace(' ',0)\n",
"df.loc[df.index,\"triples\"] = df[\"triples\"].astype(int)\n",
"df.loc[df.index,\"quadras\"] = df[\"quadras\"].replace(' ',0)\n",
"df.loc[df.index,\"quadras\"] = df[\"quadras\"].astype(int)\n",
"df.loc[df.index,\"pentas\"] = df[\"pentas\"].replace(' ',0)\n",
"df.loc[df.index,\"pentas\"] = df[\"pentas\"].astype(int)\n",
"df.loc[df.index,\"fb\"] = df[\"fb\"].astype(int)\n",
"df.loc[df.index,\"fbvictim\"] = df[\"fbvictim\"].astype(int)\n",
"df.loc[df.index,\"fbassist\"] = df[\"fbassist\"].astype(int)\n",
"df.loc[df.index,\"fd\"] = df[\"fd\"].astype(int)\n",
"df.loc[df.index,\"dmgshare\"] = df[\"dmgshare\"].replace(' ',0)\n",
"df.loc[df.index,\"dmgshare\"] = df[\"dmgshare\"].astype(float)\n",
"df.loc[df.index,\"earnedgoldshare\"] = df[\"earnedgoldshare\"].replace(' ',0)\n",
"df.loc[df.index,\"earnedgoldshare\"] = df[\"earnedgoldshare\"].astype(float)\n",
"df.loc[df.index,\"visiblewardclearrate\"] = df[\"visiblewardclearrate\"].replace(' ',0)\n",
"df.loc[df.index,\"visiblewardclearrate\"] = df[\"visiblewardclearrate\"].astype(float)\n",
"df.loc[df.index,\"invisiblewardclearrate\"] = df[\"invisiblewardclearrate\"].replace(' ',0)\n",
"df.loc[df.index,\"invisiblewardclearrate\"] = df[\"invisiblewardclearrate\"].astype(float)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df.index,\"fbtime\"] = df[\"fbtime\"].astype(float)\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df.index,\"gameid\"] = df.loc[df.index,\"gameid\"].astype(int)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"sideDict = {'Blue':0,'Red':1}\n",
"df.loc[df.index,\"side\"] = df.loc[df.index,\"side\"].replace(sideDict)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0], dtype=int64)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"positionDict = {'Top':1,'Jungle':2,'Middle':3,'ADC':4,'Support':5,'Team':0}\n",
"df.loc[df.index,\"position\"] = df.loc[df.index,\"position\"].replace(positionDict)\n",
"df[\"position\"].unique()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Team': 0}\n"
]
},
{
"data": {
"text/plain": [
"array([0], dtype=int64)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"players = df[\"player\"].unique()\n",
"playerDict = dict(zip(players, range(len(players))))\n",
"df.loc[df.index,\"player\"] = df.loc[df.index,\"player\"].replace(playerDict)\n",
"print(playerDict)\n",
"df[\"player\"].unique()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'Team Liquid': 0, 'Team SoloMid': 1, '100 Thieves': 2, 'OpTic Gaming': 3, 'Clutch Gaming': 4, 'Golden Guardians': 5, 'Echo Fox': 6, 'FlyQuest': 7, 'Counter Logic Gaming': 8, 'Cloud9': 9}\n"
]
},
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int64)"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"teams = df[\"team\"].unique()\n",
"teamDict = dict(zip(teams,range(len(teams))))\n",
"df.loc[df.index,\"team\"] = df.loc[df.index,\"team\"].replace(teamDict)\n",
"print(teamDict)\n",
"df[\"team\"].unique()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{' ': 0, 'Aatrox': 1, 'Ahri': 2, 'Akali': 3, 'Alistar': 4, 'Amumu': 5, 'Anivia': 6, 'Annie': 7, 'Aphelios': 8, 'Ashe': 9, 'AurelionSol': 10, 'Azir': 11, 'Bard': 12, 'Blitzcrank': 13, 'Brand': 14, 'Braum': 15, 'Caitlyn': 16, 'Camille': 17, 'Cassiopeia': 18, \"Cho'gath\": 19, 'Corki': 20, 'Darius': 21, 'Diana': 22, 'Dr. Mundo': 23, 'Draven': 24, 'Ekko': 25, 'Elise': 26, 'Evelynn': 27, 'Ezreal': 28, 'Fiddlesticks': 29, 'Fiora': 30, 'Fizz': 31, 'Galio': 32, 'Gangplank': 33, 'Garen': 34, 'Gnar': 35, 'Gragas': 36, 'Graves': 37, 'Hecarim': 38, 'Heimerdinger': 39, 'Illaoi': 40, 'Irelia': 41, 'Ivern': 42, 'Janna': 43, 'Jarvan IV': 44, 'Jax': 45, 'Jayce': 46, 'Jhin': 47, 'Jinx': 48, \"Kai'Sa\": 49, 'Kalista': 50, 'Karma': 51, 'Karthus': 52, 'Kassadin': 53, 'Katarina': 54, 'Kayle': 55, 'Kayn': 56, 'Kennen': 57, \"Kha'Zix\": 58, 'Kindred': 59, 'Kled': 60, \"Kog'Maw\": 61, 'LeBlanc': 62, 'Lee Sin': 63, 'Leona': 64, 'Lissandra': 65, 'Lucian': 66, 'Lulu': 67, 'Lux': 68, 'Malphite': 69, 'Malzahar': 70, 'Maokai': 71, 'Master Yi': 72, 'Miss Fortune': 73, 'Mordekaiser': 74, 'Morgana': 75, 'Nami': 76, 'Nasus': 77, 'Nautilus': 78, 'Neeko': 79, 'Nidalee': 80, 'Nocturne': 81, 'Nunu and Willump': 82, 'Olaf': 83, 'Orianna': 84, 'Ornn': 85, 'Pantheon': 86, 'Poppy': 87, 'Pyke': 88, 'Qiyana': 89, 'Quinn': 90, 'Rakan': 91, 'Rammus': 92, \"Rek'Sai\": 93, 'Renekton': 94, 'Rengar': 95, 'Riven': 96, 'Rumble': 97, 'Ryze': 98, 'Sejuani': 99, 'Senna': 100, 'Sett': 101, 'Shaco': 102, 'Shen': 103, 'Shyvana': 104, 'Singed': 105, 'Sion': 106, 'Sivir': 107, 'Skarner': 108, 'Sona': 109, 'Soraka': 110, 'Swain': 111, 'Sylas': 112, 'Syndra': 113, 'Tahm Kench': 114, 'Taliyah': 115, 'Talon': 116, 'Taric': 117, 'Teemo': 118, 'Thresh': 119, 'Tristana': 120, 'Trundle': 121, 'Tryndamere': 122, 'TwistedFate': 123, 'Twitch': 124, 'Udyr': 125, 'Urgot': 126, 'Varus': 127, 'Vayne': 128, 'Veigar': 129, \"Vel'koz\": 130, 'Vi': 131, 'Viktor': 132, 'Vladimir': 133, 'Volibear': 134, 'Warwick': 135, 'Wukong': 136, 'Xayah': 137, 'Xerath': 138, 'Xin Zhao': 139, 'Yasuo': 140, 'Yorick': 141, 'Yuumi': 142, 'Zac': 143, 'Zed': 144, 'Ziggs': 145, 'Zilean': 146, 'Zoe': 147, 'Zyra': 148}\n"
]
}
],
"source": [
"champ = [' ','Aatrox','Ahri','Akali','Alistar','Amumu','Anivia','Annie','Aphelios','Ashe','Aurelion' 'Sol','Azir','Bard','Blitzcrank','Brand','Braum','Caitlyn','Camille','Cassiopeia',\"Cho'gath\",'Corki','Darius','Diana',\"Dr. Mundo\",'Draven','Ekko','Elise','Evelynn','Ezreal','Fiddlesticks','Fiora','Fizz','Galio','Gangplank','Garen','Gnar','Gragas','Graves','Hecarim','Heimerdinger','Illaoi','Irelia','Ivern','Janna',\"Jarvan IV\",'Jax','Jayce','Jhin','Jinx',\"Kai'Sa\",'Kalista','Karma','Karthus','Kassadin','Katarina','Kayle','Kayn','Kennen',\"Kha'Zix\",'Kindred','Kled',\"Kog'Maw\",'LeBlanc','Lee Sin','Leona','Lissandra','Lucian','Lulu','Lux','Malphite','Malzahar','Maokai','Master Yi','Miss Fortune','Mordekaiser','Morgana','Nami','Nasus','Nautilus','Neeko','Nidalee','Nocturne',\"Nunu and Willump\",'Olaf','Orianna','Ornn','Pantheon','Poppy','Pyke','Qiyana','Quinn','Rakan','Rammus',\"Rek'Sai\",'Renekton','Rengar','Riven','Rumble','Ryze','Sejuani','Senna','Sett','Shaco','Shen','Shyvana','Singed','Sion','Sivir','Skarner','Sona','Soraka','Swain','Sylas','Syndra','Tahm Kench','Taliyah','Talon','Taric','Teemo','Thresh','Tristana','Trundle','Tryndamere','Twisted' 'Fate','Twitch','Udyr','Urgot','Varus','Vayne','Veigar',\"Vel'koz\",'Vi','Viktor','Vladimir','Volibear','Warwick','Wukong','Xayah','Xerath',\"Xin Zhao\",'Yasuo','Yorick','Yuumi','Zac','Zed','Ziggs','Zilean','Zoe','Zyra']\n",
"champDict = dict(zip(champ, range(len(champ))))\n",
"print(champDict)\n",
"#df[\"champion\"].unique()\n",
"df.loc[df.index,\"champion\"] = df.loc[df.index,\"champion\"].replace(champDict)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"df.loc[df.index,\"ban1\"] = df.loc[df.index,\"ban1\"].replace(champDict)\n",
"df.loc[df.index,\"ban2\"] = df.loc[df.index,\"ban2\"].replace(champDict)\n",
"df.loc[df.index,\"ban3\"] = df.loc[df.index,\"ban3\"].replace(champDict)\n",
"df.loc[df.index,\"ban4\"] = df.loc[df.index,\"ban4\"].replace(champDict)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([\"Kha'zix\", 103, 85, 35, 4, 98, 46, 43, 27, 44, 75, 61, 143, 17, 95,\n",
" 117, 133, 127, 30, 99, 107, 70, 28, 119, 33, 120, 'Aurelion Sol',\n",
" 50, 114, 115, 20, 91, 108, 137, 18, 16, 'Twisted Fate', 132, 15,\n",
" 106, 84, 40, 19, 93, 121, 148, 51, 11, 60, 12, 62, 113, 6, 48, 32,\n",
" 47], dtype=object)"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df.index,\"ban5\"] = df.loc[df.index,\"ban5\"].replace(champDict)\n",
"df[\"ban5\"].unique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'naDF' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-19-36f4d4679e14>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnaDF\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mto_csv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"naLCSTeamsNumericalized.csv\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mNameError\u001b[0m: name 'naDF' is not defined"
]
}
],
"source": [
"df.to_csv(\"naLCSTeamsNumericalized.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment