{ "cells": [ { "cell_type": "code", "execution_count": 73, "id": "2f27067c-4b22-4f2e-b467-427467475fa6", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import math\n", "import time\n", "import yaml\n", "import os" ] }, { "cell_type": "code", "execution_count": 83, "id": "df1442eb-fb81-43c5-9b22-2cff7b794da0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'D:\\\\PycharmProjects\\\\TerraBot\\\\faction-picker-bot'" ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "_dh[0]" ] }, { "cell_type": "code", "execution_count": 76, "id": "708c5ce7-eed3-4449-9140-1f41e8865b66", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['In',\n", " 'Out',\n", " '_',\n", " '_11',\n", " '_12',\n", " '_14',\n", " '_15',\n", " '_17',\n", " '_19',\n", " '_2',\n", " '_20',\n", " '_21',\n", " '_33',\n", " '_34',\n", " '_35',\n", " '_36',\n", " '_37',\n", " '_38',\n", " '_39',\n", " '_40',\n", " '_42',\n", " '_43',\n", " '_44',\n", " '_45',\n", " '_46',\n", " '_47',\n", " '_48',\n", " '_49',\n", " '_50',\n", " '_51',\n", " '_52',\n", " '_53',\n", " '_54',\n", " '_55',\n", " '_56',\n", " '_57',\n", " '_58',\n", " '_59',\n", " '_6',\n", " '_63',\n", " '_64',\n", " '_8',\n", " '_9',\n", " '__',\n", " '___',\n", " '__builtin__',\n", " '__builtins__',\n", " '__doc__',\n", " '__loader__',\n", " '__name__',\n", " '__package__',\n", " '__spec__',\n", " '_dh',\n", " '_i',\n", " '_i1',\n", " '_i10',\n", " '_i11',\n", " '_i12',\n", " '_i13',\n", " '_i14',\n", " '_i15',\n", " '_i16',\n", " '_i17',\n", " '_i18',\n", " '_i19',\n", " '_i2',\n", " '_i20',\n", " '_i21',\n", " '_i22',\n", " '_i23',\n", " '_i24',\n", " '_i25',\n", " '_i26',\n", " '_i27',\n", " '_i28',\n", " '_i29',\n", " '_i3',\n", " '_i30',\n", " '_i31',\n", " '_i32',\n", " '_i33',\n", " '_i34',\n", " '_i35',\n", " '_i36',\n", " '_i37',\n", " '_i38',\n", " '_i39',\n", " '_i4',\n", " '_i40',\n", " '_i41',\n", " '_i42',\n", " '_i43',\n", " '_i44',\n", " '_i45',\n", " '_i46',\n", " '_i47',\n", " '_i48',\n", " '_i49',\n", " '_i5',\n", " '_i50',\n", " '_i51',\n", " '_i52',\n", " '_i53',\n", " '_i54',\n", " '_i55',\n", " '_i56',\n", " '_i57',\n", " '_i58',\n", " '_i59',\n", " '_i6',\n", " '_i60',\n", " '_i61',\n", " '_i62',\n", " '_i63',\n", " '_i64',\n", " '_i65',\n", " '_i66',\n", " '_i67',\n", " '_i68',\n", " '_i69',\n", " '_i7',\n", " '_i70',\n", " '_i71',\n", " '_i72',\n", " '_i73',\n", " '_i74',\n", " '_i75',\n", " '_i76',\n", " '_i8',\n", " '_i9',\n", " '_ih',\n", " '_ii',\n", " '_iii',\n", " '_oh',\n", " 'allmermaids',\n", " 'colnames',\n", " 'each_faction_dataset',\n", " 'exit',\n", " 'faction',\n", " 'faction_dataset',\n", " 'factions',\n", " 'featdf',\n", " 'get_ipython',\n", " 'indexes',\n", " 'indexs',\n", " 'math',\n", " 'np',\n", " 'os',\n", " 'pd',\n", " 'quit',\n", " 'time',\n", " 'vpdf',\n", " 'yaml']" ] }, "execution_count": 76, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir()" ] }, { "cell_type": "code", "execution_count": 90, "id": "b51ade6d-f3df-4c59-95bb-f1e1df99cf75", "metadata": {}, "outputs": [], "source": [ "script_dir = os.path.dirname(_dh[0])\n", "filename = os.path.join(script_dir, 'params.yaml')" ] }, { "cell_type": "code", "execution_count": 91, "id": "7fdcd13e-011c-4349-86b1-f00098edc00c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'D:\\\\PycharmProjects\\\\TerraBot\\\\params.yaml'" ] }, "execution_count": 91, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filename" ] }, { "cell_type": "code", "execution_count": 2, "id": "abc42db1-fdda-48f9-ac22-73ab04e07658", "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'yaml' 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\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"../params.yaml\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mfd\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mparams\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0myaml\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msafe_load\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfd\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 'yaml' is not defined" ] } ], "source": [ "with open(\"../params.yaml\", 'r') as fd:\n", " params = yaml.safe_load(fd)" ] }, { "cell_type": "code", "execution_count": 2, "id": "941150cc-5223-4984-8981-808021c5ce55", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0gamewitchesaurenswarmlingsmermaidscultistshalflingsdwarvesengineerschaosmagiciansgiantsfakirsnomadsdarklingsalchemists
000000000001NaNNaNNaN118.0NaN62.0NaNNaNNaNNaNNaNNaNNaNNaN
11050615NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN122.0NaN
220512NaNNaNNaNNaNNaNNaNNaN124.0101.0NaNNaNNaNNaNNaN
33051501NaN84.0NaNNaNNaN77.0NaNNaN72.0NaNNaN54.078.0NaN
44060303NaNNaNNaN108.0NaNNaNNaN121.0NaNNaN78.0NaN128.0NaN
...................................................
111541111541YoureacrookcaptianhookNaNNaN126.0NaNNaN105.0NaNNaNNaNNaNNaN37.0NaNNaN
111542111542YourMomIsAChaosMagician112.0NaN114.0NaNNaNNaNNaNNaNNaNNaNNaN120.0NaNNaN
111543111543ytuwertqwtrNaNNaN105.0NaNNaNNaN102.0NaNNaNNaNNaNNaNNaNNaN
111544111544yuertyqert128.0NaNNaNNaNNaNNaNNaNNaN141.0NaNNaNNaNNaNNaN
111545111545ZeicheMasZeuchnisNaNNaNNaNNaNNaNNaN132.0NaNNaNNaNNaN88.0120.0NaN
\n", "

111546 rows × 16 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 game witches auren swarmlings \\\n", "0 0 0000000001 NaN NaN NaN \n", "1 1 050615 NaN NaN NaN \n", "2 2 0512 NaN NaN NaN \n", "3 3 051501 NaN 84.0 NaN \n", "4 4 060303 NaN NaN NaN \n", "... ... ... ... ... ... \n", "111541 111541 Youreacrookcaptianhook NaN NaN 126.0 \n", "111542 111542 YourMomIsAChaosMagician 112.0 NaN 114.0 \n", "111543 111543 ytuwertqwtr NaN NaN 105.0 \n", "111544 111544 yuertyqert 128.0 NaN NaN \n", "111545 111545 ZeicheMasZeuchnis NaN NaN NaN \n", "\n", " mermaids cultists halflings dwarves engineers chaosmagicians \\\n", "0 118.0 NaN 62.0 NaN NaN NaN \n", "1 NaN NaN NaN NaN NaN NaN \n", "2 NaN NaN NaN NaN 124.0 101.0 \n", "3 NaN NaN 77.0 NaN NaN 72.0 \n", "4 108.0 NaN NaN NaN 121.0 NaN \n", "... ... ... ... ... ... ... \n", "111541 NaN NaN 105.0 NaN NaN NaN \n", "111542 NaN NaN NaN NaN NaN NaN \n", "111543 NaN NaN NaN 102.0 NaN NaN \n", "111544 NaN NaN NaN NaN NaN 141.0 \n", "111545 NaN NaN NaN 132.0 NaN NaN \n", "\n", " giants fakirs nomads darklings alchemists \n", "0 NaN NaN NaN NaN NaN \n", "1 NaN NaN NaN 122.0 NaN \n", "2 NaN NaN NaN NaN NaN \n", "3 NaN NaN 54.0 78.0 NaN \n", "4 NaN 78.0 NaN 128.0 NaN \n", "... ... ... ... ... ... \n", "111541 NaN NaN 37.0 NaN NaN \n", "111542 NaN NaN 120.0 NaN NaN \n", "111543 NaN NaN NaN NaN NaN \n", "111544 NaN NaN NaN NaN NaN \n", "111545 NaN NaN 88.0 120.0 NaN \n", "\n", "[111546 rows x 16 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vpdf = pd.read_csv('D://PycharmProjects/TerraBot/data/faction-picker-bot/vpdata.csv')\n", "featdf = pd.read_csv('D://PycharmProjects/TerraBot/data/faction-picker-bot/featdata.csv')\n", "\n", "# split in 12 faction data\n", "vpdf" ] }, { "cell_type": "code", "execution_count": 66, "id": "db0b961f-c751-439d-8583-da459db2d6d6", "metadata": {}, "outputs": [], "source": [ "colnames = list(vpdf.columns)\n", "factions = [x for x in colnames if x != 'game' and x != 'Unnamed: 0']" ] }, { "cell_type": "code", "execution_count": 15, "id": "657af1ef-3338-4c27-b7a2-dbfe7ab959ed", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 False\n", "1 True\n", "2 True\n", "3 True\n", "4 False\n", " ... \n", "111541 True\n", "111542 True\n", "111543 True\n", "111544 True\n", "111545 True\n", "Name: mermaids, Length: 111546, dtype: bool" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "indexs = pd.isnull(vpdf['mermaids'])" ] }, { "cell_type": "code", "execution_count": 62, "id": "5ed90fe5-75b1-47db-957d-deeeaf750f02", "metadata": {}, "outputs": [], "source": [ "allmermaids = vpdf['mermaids'][~indexs]" ] }, { "cell_type": "code", "execution_count": 63, "id": "788e7f43-8e25-4b53-b4be-98eefee1ae85", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 118.0\n", "4 108.0\n", "6 104.0\n", "9 106.0\n", "21 140.0\n", " ... \n", "111522 98.0\n", "111525 90.0\n", "111535 68.0\n", "111537 85.0\n", "111538 136.0\n", "Name: mermaids, Length: 33442, dtype: float64" ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "allmermaids" ] }, { "cell_type": "code", "execution_count": 64, "id": "282694f1-2c1a-4b55-920a-791d50ea7946", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0gamer1_SCORE1r1_SCORE2r1_SCORE3r1_SCORE4r1_SCORE5r1_SCORE6r1_SCORE7r1_SCORE8...BON8BON9BON102players3players4players5playersmap1map2map3
00000000000100000001...0111000100
4406030301000000...1110010010
6607031501000000...1110010100
990pandoraravenclaw01000000...0001000100
212116JULY201500001000...0100010100
..................................................................
111522111522WelcomeFastPlayer00001000...1100010100
111525111525WhatsForLunch00001000...1001000100
111535111535XiangIsDumb00100000...1100100100
111537111537XxxX0110000000...1010100100
111538111538Yellowsubmarine00100000...0110100100
\n", "

33442 rows × 73 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 game r1_SCORE1 r1_SCORE2 r1_SCORE3 \\\n", "0 0 0000000001 0 0 0 \n", "4 4 060303 0 1 0 \n", "6 6 070315 0 1 0 \n", "9 9 0pandoraravenclaw 0 1 0 \n", "21 21 16JULY2015 0 0 0 \n", "... ... ... ... ... ... \n", "111522 111522 WelcomeFastPlayer 0 0 0 \n", "111525 111525 WhatsForLunch 0 0 0 \n", "111535 111535 XiangIsDumb 0 0 1 \n", "111537 111537 XxxX01 1 0 0 \n", "111538 111538 Yellowsubmarine 0 0 1 \n", "\n", " r1_SCORE4 r1_SCORE5 r1_SCORE6 r1_SCORE7 r1_SCORE8 ... BON8 \\\n", "0 0 0 0 0 1 ... 0 \n", "4 0 0 0 0 0 ... 1 \n", "6 0 0 0 0 0 ... 1 \n", "9 0 0 0 0 0 ... 0 \n", "21 0 1 0 0 0 ... 0 \n", "... ... ... ... ... ... ... ... \n", "111522 0 1 0 0 0 ... 1 \n", "111525 0 1 0 0 0 ... 1 \n", "111535 0 0 0 0 0 ... 1 \n", "111537 0 0 0 0 0 ... 1 \n", "111538 0 0 0 0 0 ... 0 \n", "\n", " BON9 BON10 2players 3players 4players 5players map1 map2 map3 \n", "0 1 1 1 0 0 0 1 0 0 \n", "4 1 1 0 0 1 0 0 1 0 \n", "6 1 1 0 0 1 0 1 0 0 \n", "9 0 0 1 0 0 0 1 0 0 \n", "21 1 0 0 0 1 0 1 0 0 \n", "... ... ... ... ... ... ... ... ... ... \n", "111522 1 0 0 0 1 0 1 0 0 \n", "111525 0 0 1 0 0 0 1 0 0 \n", "111535 1 0 0 1 0 0 1 0 0 \n", "111537 0 1 0 1 0 0 1 0 0 \n", "111538 1 1 0 1 0 0 1 0 0 \n", "\n", "[33442 rows x 73 columns]" ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "featdf[~indexs]" ] }, { "cell_type": "code", "execution_count": 67, "id": "a101ac03-1fe7-452f-a7b2-ad702136de81", "metadata": {}, "outputs": [], "source": [ "each_faction_dataset = {}\n", "for faction in factions:\n", " faction_dataset = {}\n", " indexes = pd.isnull(vpdf[faction])\n", " faction_dataset['vp'] = vpdf[faction][~indexes]\n", " faction_dataset['features'] = featdf[~indexs]\n", " each_faction_dataset[faction] = faction_dataset\n", " " ] }, { "cell_type": "code", "execution_count": null, "id": "60fd33be-c671-4112-9112-22b38df7fe08", "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.4" } }, "nbformat": 4, "nbformat_minor": 5 }