aoe2-data/jupyter-data/AoE-data.ipynb
2023-03-29 18:13:06 +02:00

333 lines
7.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 16,
"id": "4817ec9b-c8e3-45a4-97dc-acee536e4d77",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import requests\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a05a0d5e-012e-46b8-a52c-7f8a3a412e62",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"nac4_finals_draft_id='FMHZx'"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "16438549-78b6-4865-ba7d-fb90486579e3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def download_draft_json(draft_id):\n",
" url = \"https://aoe2cm.net/api/draft/{}\".format(draft_id)\n",
"\n",
" payload={}\n",
" headers = {}\n",
"\n",
" response = requests.request(\"GET\", url, headers=headers, data=payload)\n",
"\n",
" # print(response.text)\n",
" draft_json_string = response.text\n",
" draft_dict = json.loads(draft_json_string)\n",
" return draft_dict"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "527953cb-e30f-4599-a5e6-b5f8ce3b678d",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# draft_dict['events']"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "4f068845-8292-4b38-bd2b-0d89a2eea434",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"marcel_vs_canuck= 'lipeX'"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "8a375968-3d08-46e2-b7be-45a926de40f1",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"marcel_vs_canuck_json = download_draft_json(marcel_vs_canuck)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "69ecf8fd-b437-4632-9f6e-1172a34badf0",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# marcel_vs_canuck_json"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "c45783ac-50c0-4cf2-b451-23d11b5f5079",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "a9f08fa9-4f90-4ba1-a639-78ec888ac86c",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"draft_events = marcel_vs_canuck_json['events']"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "527935c9-1f49-4c7f-8b4a-b95475a66068",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"draft_events_df = pd.DataFrame.from_dict(draft_events)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "7e2bb0c3-ab79-4e95-94f7-52a590e8dfe6",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"draft_picks = draft_events_df[draft_events_df['actionType'] == 'pick']"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "99dedcda-5664-492b-a076-7fe059948660",
"metadata": {
"tags": []
},
"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>player</th>\n",
" <th>executingPlayer</th>\n",
" <th>actionType</th>\n",
" <th>chosenOptionId</th>\n",
" <th>isRandomlyChosen</th>\n",
" <th>offset</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>HOST</td>\n",
" <td>HOST</td>\n",
" <td>pick</td>\n",
" <td>Koala</td>\n",
" <td>False</td>\n",
" <td>13973</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>GUEST</td>\n",
" <td>GUEST</td>\n",
" <td>pick</td>\n",
" <td>Nordinseln</td>\n",
" <td>False</td>\n",
" <td>26925</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>HOST</td>\n",
" <td>HOST</td>\n",
" <td>pick</td>\n",
" <td>Vier Seen</td>\n",
" <td>False</td>\n",
" <td>54947</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" player executingPlayer actionType chosenOptionId isRandomlyChosen offset\n",
"2 HOST HOST pick Koala False 13973\n",
"3 GUEST GUEST pick Nordinseln False 26925\n",
"8 HOST HOST pick Vier Seen False 54947"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"draft_picks"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17a9c895-c486-4b53-b34d-917e6e94d0fc",
"metadata": {},
"outputs": [],
"source": [
"# the last pick is the neutral map\n",
"def mark_neutral_map(draft_picks):\n",
" draft_picks.\n",
" draft_picks['neutral_map'] = "
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "1a82cae5-dd3d-4799-baa1-be30f550d19b",
"metadata": {
"tags": []
},
"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>player</th>\n",
" <th>executingPlayer</th>\n",
" <th>actionType</th>\n",
" <th>chosenOptionId</th>\n",
" <th>isRandomlyChosen</th>\n",
" <th>offset</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>HOST</td>\n",
" <td>HOST</td>\n",
" <td>pick</td>\n",
" <td>Vier Seen</td>\n",
" <td>False</td>\n",
" <td>54947</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" player executingPlayer actionType chosenOptionId isRandomlyChosen offset\n",
"8 HOST HOST pick Vier Seen False 54947"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"draft_picks.tail(1)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}