This commit is contained in:
dechert
2023-03-30 16:01:38 +02:00
parent 4332a35f4a
commit 21d25b618d
8 changed files with 1 additions and 2 deletions

Binary file not shown.

140
jupyter/src/AoE-data.ipynb Normal file
View File

@@ -0,0 +1,140 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "53445797-52c4-4443-8095-889cf1c24298",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%load_ext autoreload\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4de950c8-cabe-4874-aa78-548342993b05",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%autoreload 1"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a121cdfe-114a-4aae-b107-df891338dfcc",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import drafts"
]
},
{
"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": 5,
"id": "4f068845-8292-4b38-bd2b-0d89a2eea434",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"marcel_vs_canuck= 'lipeX'"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8a375968-3d08-46e2-b7be-45a926de40f1",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"marcel_vs_canuck_json = drafts.download_draft_json(marcel_vs_canuck)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "fa4e0d16-e397-4ff5-8a70-87e6e6cacba9",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"draft_picks=drafts.get_picked_maps(marcel_vs_canuck_json)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "a668fe2a-9006-4987-86bc-2179ebdfd0a2",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"'Vier Seen'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"drafts.neutral_map_as_string(draft_picks)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7b337190-7887-40b7-9d10-b8039f5f2dfd",
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}

27
jupyter/src/drafts.py Normal file
View File

@@ -0,0 +1,27 @@
import requests
import json
import pandas as pd
def download_draft_json(draft_id):
url = "https://aoe2cm.net/api/draft/{}".format(draft_id)
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
# print(response.text)
draft_json_string = response.text
draft_dict = json.loads(draft_json_string)
return draft_dict
def get_picked_maps(draft_json):
draft_events = draft_json['events']
draft_events_df = pd.DataFrame.from_dict(draft_events)
draft_picks = draft_events_df[draft_events_df['actionType'] == 'pick']
return draft_picks
# the last pick is the neutral map
def neutral_map_as_string(draft_picks):
# print(draft_picks.tail(1)['chosenOptionId'])
return str(draft_picks.tail(1)['chosenOptionId'][8])