Code updated for Serie A 2023/2024
- Reorganization of data folders - Code adapted for the new Serie A season, also considering only a small number of league games has been played - Stats from other leagues are considered for players at their first Serie A season (rookies), for now without any adaptation based on league difficulty - Minor fixes
This commit is contained in:
+143
-367
@@ -85,32 +85,32 @@
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Fiorentina</td>\n",
|
||||
" <td>Cremonese</td>\n",
|
||||
" <td>Bologna</td>\n",
|
||||
" <td>Milan</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Empoli</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Napoli</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Juventus</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>Frosinone</td>\n",
|
||||
" <td>Napoli</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Lazio</td>\n",
|
||||
" <td>Bologna</td>\n",
|
||||
" <td>Genoa</td>\n",
|
||||
" <td>Fiorentina</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Lecce</td>\n",
|
||||
" <td>Inter</td>\n",
|
||||
" <td>Monza</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
@@ -121,32 +121,32 @@
|
||||
" <tr>\n",
|
||||
" <th>375</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Lecce</td>\n",
|
||||
" <td>Bologna</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Inter</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>376</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>Fiorentina</td>\n",
|
||||
" <td>Juventus</td>\n",
|
||||
" <td>Monza</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>377</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Milan</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Lazio</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>378</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Torino</td>\n",
|
||||
" <td>Inter</td>\n",
|
||||
" <td>Milan</td>\n",
|
||||
" <td>Salernitana</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>379</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Udinese</td>\n",
|
||||
" <td>Juventus</td>\n",
|
||||
" <td>Napoli</td>\n",
|
||||
" <td>Lecce</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
@@ -154,18 +154,18 @@
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" matchday team1 team2\n",
|
||||
"0 1 Fiorentina Cremonese\n",
|
||||
"1 1 Verona Napoli\n",
|
||||
"2 1 Juventus Sassuolo\n",
|
||||
"3 1 Lazio Bologna\n",
|
||||
"4 1 Lecce Inter\n",
|
||||
".. ... ... ...\n",
|
||||
"375 38 Lecce Bologna\n",
|
||||
"376 38 Sassuolo Fiorentina\n",
|
||||
"377 38 Milan Verona\n",
|
||||
"378 38 Torino Inter\n",
|
||||
"379 38 Udinese Juventus\n",
|
||||
" matchday team1 team2\n",
|
||||
"0 1 Bologna Milan\n",
|
||||
"1 1 Empoli Verona\n",
|
||||
"2 1 Frosinone Napoli\n",
|
||||
"3 1 Genoa Fiorentina\n",
|
||||
"4 1 Inter Monza\n",
|
||||
".. ... ... ...\n",
|
||||
"375 38 Verona Inter\n",
|
||||
"376 38 Juventus Monza\n",
|
||||
"377 38 Lazio Sassuolo\n",
|
||||
"378 38 Milan Salernitana\n",
|
||||
"379 38 Napoli Lecce\n",
|
||||
"\n",
|
||||
"[380 rows x 3 columns]"
|
||||
]
|
||||
@@ -191,36 +191,7 @@
|
||||
"text": [
|
||||
"loaded votes for matchday 1\n",
|
||||
"loaded votes for matchday 2\n",
|
||||
"loaded votes for matchday 3\n",
|
||||
"loaded votes for matchday 4\n",
|
||||
"loaded votes for matchday 5\n",
|
||||
"loaded votes for matchday 6\n",
|
||||
"loaded votes for matchday 7\n",
|
||||
"loaded votes for matchday 8\n",
|
||||
"loaded votes for matchday 9\n",
|
||||
"loaded votes for matchday 10\n",
|
||||
"loaded votes for matchday 11\n",
|
||||
"loaded votes for matchday 12\n",
|
||||
"loaded votes for matchday 13\n",
|
||||
"loaded votes for matchday 14\n",
|
||||
"loaded votes for matchday 15\n",
|
||||
"loaded votes for matchday 16\n",
|
||||
"loaded votes for matchday 17\n",
|
||||
"loaded votes for matchday 18\n",
|
||||
"loaded votes for matchday 19\n",
|
||||
"loaded votes for matchday 20\n",
|
||||
"loaded votes for matchday 21\n",
|
||||
"loaded votes for matchday 22\n",
|
||||
"loaded votes for matchday 23\n",
|
||||
"loaded votes for matchday 24\n",
|
||||
"loaded votes for matchday 25\n",
|
||||
"loaded votes for matchday 26\n",
|
||||
"loaded votes for matchday 27\n",
|
||||
"loaded votes for matchday 28\n",
|
||||
"loaded votes for matchday 29\n",
|
||||
"loaded votes for matchday 30\n",
|
||||
"loaded votes for matchday 31\n",
|
||||
"loaded votes for matchday 32\n"
|
||||
"loaded votes for matchday 3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -231,7 +202,7 @@
|
||||
"\n",
|
||||
"for matchday in range(1, LAST_MATCH + 1):\n",
|
||||
" \n",
|
||||
" votes_file = 'fantacalcio/voti/Voti_Fantacalcio_Stagione_2022_23_Giornata_' + str(matchday) + '.xlsx'\n",
|
||||
" votes_file = 'fantacalcio/voti/Voti_Fantacalcio_Stagione_2023_24_Giornata_' + str(matchday) + '.xlsx'\n",
|
||||
"\n",
|
||||
" try:\n",
|
||||
" rx = np.array(pd.read_excel(votes_file, header = None))\n",
|
||||
@@ -328,33 +299,33 @@
|
||||
" <td>1</td>\n",
|
||||
" <td>Musso</td>\n",
|
||||
" <td>Atalanta</td>\n",
|
||||
" <td>Sampdoria</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.5</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Toloi</td>\n",
|
||||
" <td>Zappacosta</td>\n",
|
||||
" <td>Atalanta</td>\n",
|
||||
" <td>Sampdoria</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>7.0</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>10.0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Djimsiti</td>\n",
|
||||
" <td>Atalanta</td>\n",
|
||||
" <td>Sampdoria</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
@@ -365,28 +336,28 @@
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Hateboer</td>\n",
|
||||
" <td>Kolasinac</td>\n",
|
||||
" <td>Atalanta</td>\n",
|
||||
" <td>Sampdoria</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.5</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Okoli</td>\n",
|
||||
" <td>Zortea</td>\n",
|
||||
" <td>Atalanta</td>\n",
|
||||
" <td>Sampdoria</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" <td>7.0</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.5</td>\n",
|
||||
" <td>5.0</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>10.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
@@ -402,24 +373,24 @@
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>9097</th>\n",
|
||||
" <td>32</td>\n",
|
||||
" <td>Terracciano F.</td>\n",
|
||||
" <th>859</th>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>Folorunsho</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Cremonese</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" <td>5.0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" <td>5.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>9098</th>\n",
|
||||
" <td>32</td>\n",
|
||||
" <td>Abildgaard</td>\n",
|
||||
" <th>860</th>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>Serdar</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Cremonese</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" <td>0</td>\n",
|
||||
@@ -428,11 +399,11 @@
|
||||
" <td>5.5</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>9099</th>\n",
|
||||
" <td>32</td>\n",
|
||||
" <td>Braaf</td>\n",
|
||||
" <th>861</th>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>Bonazzoli</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Cremonese</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" <td>0</td>\n",
|
||||
@@ -441,24 +412,11 @@
|
||||
" <td>5.5</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>9100</th>\n",
|
||||
" <td>32</td>\n",
|
||||
" <td>Kallon</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Cremonese</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>5.5</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>9101</th>\n",
|
||||
" <td>32</td>\n",
|
||||
" <th>862</th>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>Djuric</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Cremonese</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" <td>0</td>\n",
|
||||
@@ -466,39 +424,52 @@
|
||||
" <td>0.0</td>\n",
|
||||
" <td>6.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>863</th>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>Ngonge</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>6.5</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>0</td>\n",
|
||||
" <td>0.0</td>\n",
|
||||
" <td>9.5</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>9102 rows × 10 columns</p>\n",
|
||||
"<p>864 rows × 10 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" matchday player team oppteam home vote goals assists \\\n",
|
||||
"0 1 Musso Atalanta Sampdoria 0 6.0 0 0 \n",
|
||||
"1 1 Toloi Atalanta Sampdoria 0 7.0 1 0 \n",
|
||||
"2 1 Djimsiti Atalanta Sampdoria 0 6.0 0 0 \n",
|
||||
"3 1 Hateboer Atalanta Sampdoria 0 6.0 0 0 \n",
|
||||
"4 1 Okoli Atalanta Sampdoria 0 5.5 0 0 \n",
|
||||
"... ... ... ... ... ... ... ... ... \n",
|
||||
"9097 32 Terracciano F. Verona Cremonese 0 6.0 0 0 \n",
|
||||
"9098 32 Abildgaard Verona Cremonese 0 5.5 0 0 \n",
|
||||
"9099 32 Braaf Verona Cremonese 0 5.5 0 0 \n",
|
||||
"9100 32 Kallon Verona Cremonese 0 5.5 0 0 \n",
|
||||
"9101 32 Djuric Verona Cremonese 0 6.0 0 0 \n",
|
||||
" matchday player team oppteam home vote goals assists \\\n",
|
||||
"0 1 Musso Atalanta Sassuolo 0 6.5 0 0 \n",
|
||||
"1 1 Zappacosta Atalanta Sassuolo 0 6.5 0 0 \n",
|
||||
"2 1 Djimsiti Atalanta Sassuolo 0 6.0 0 0 \n",
|
||||
"3 1 Kolasinac Atalanta Sassuolo 0 6.5 0 0 \n",
|
||||
"4 1 Zortea Atalanta Sassuolo 0 7.0 1 0 \n",
|
||||
".. ... ... ... ... ... ... ... ... \n",
|
||||
"859 3 Folorunsho Verona Sassuolo 0 5.0 0 0 \n",
|
||||
"860 3 Serdar Verona Sassuolo 0 5.5 0 0 \n",
|
||||
"861 3 Bonazzoli Verona Sassuolo 0 5.5 0 0 \n",
|
||||
"862 3 Djuric Verona Sassuolo 0 6.0 0 0 \n",
|
||||
"863 3 Ngonge Verona Sassuolo 0 6.5 1 0 \n",
|
||||
"\n",
|
||||
" cards_malus fantavote \n",
|
||||
"0 0.5 5.5 \n",
|
||||
"1 0.0 10.0 \n",
|
||||
"2 0.0 6.0 \n",
|
||||
"3 0.5 5.5 \n",
|
||||
"4 0.5 5.0 \n",
|
||||
"... ... ... \n",
|
||||
"9097 0.0 6.0 \n",
|
||||
"9098 0.0 5.5 \n",
|
||||
"9099 0.0 5.5 \n",
|
||||
"9100 0.0 5.5 \n",
|
||||
"9101 0.0 6.0 \n",
|
||||
" cards_malus fantavote \n",
|
||||
"0 0.0 6.5 \n",
|
||||
"1 0.0 6.5 \n",
|
||||
"2 0.0 6.0 \n",
|
||||
"3 0.0 6.5 \n",
|
||||
"4 0.0 10.0 \n",
|
||||
".. ... ... \n",
|
||||
"859 0.0 5.0 \n",
|
||||
"860 0.0 5.5 \n",
|
||||
"861 0.0 5.5 \n",
|
||||
"862 0.0 6.0 \n",
|
||||
"863 0.0 9.5 \n",
|
||||
"\n",
|
||||
"[9102 rows x 10 columns]"
|
||||
"[864 rows x 10 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
@@ -532,7 +503,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 13,
|
||||
"id": "da35bdf9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -651,12 +622,14 @@
|
||||
"[380 rows x 3 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# BACKUP CODE FOR SEASON 2122 and 2021 (different calendar file format than 2223 and 2324)\n",
|
||||
"\n",
|
||||
"cal_df = pd.read_excel('fantacalcio/season2122/seriea_calendar.xlsx')\n",
|
||||
"\n",
|
||||
"to_drop = list()\n",
|
||||
@@ -674,7 +647,33 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 14,
|
||||
"id": "a0b100da",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cal = np.array(pd.read_excel('fantacalcio/season2223/seriea_calendar.xlsx', header = None))\n",
|
||||
"\n",
|
||||
"cal_df = pd.DataFrame(columns = ['matchday', 'team1', 'team2'])\n",
|
||||
"\n",
|
||||
"matchday = 0\n",
|
||||
"\n",
|
||||
"for i in range(cal.shape[0]):\n",
|
||||
" if(cal[i, 0][0].isnumeric()):\n",
|
||||
" matchday = matchday + 1\n",
|
||||
" continue\n",
|
||||
" \n",
|
||||
" teams = cal[i, 0].split('-')\n",
|
||||
" \n",
|
||||
" frame = pd.DataFrame([[matchday, teams[0], teams[1]]], columns = cal_df.columns)\n",
|
||||
"\n",
|
||||
" cal_df = pd.concat([cal_df, frame], ignore_index = True)\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"id": "0313a0f4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -685,7 +684,7 @@
|
||||
"\n",
|
||||
"for matchday in range(1, LAST_MATCH + 1):\n",
|
||||
" \n",
|
||||
" votes_file = 'fantacalcio/season2122/voti/Voti_Fantacalcio_Stagione_2021_22_Giornata_' + str(matchday) + '.xlsx'\n",
|
||||
" votes_file = 'fantacalcio/season2223/voti/Voti_Fantacalcio_Stagione_2022_23_Giornata_' + str(matchday) + '.xlsx'\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -737,236 +736,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 16,
|
||||
"id": "82b1cfc8",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.to_excel('mid_outputs/season2122/players_votes.xlsx')"
|
||||
"df.to_excel('mid_outputs/season2223/players_votes.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "d1fca3ba",
|
||||
"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>matchday</th>\n",
|
||||
" <th>team1</th>\n",
|
||||
" <th>team2</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Fiorentina</td>\n",
|
||||
" <td>Torino</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" <td>Roma</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Parma</td>\n",
|
||||
" <td>Napoli</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Genoa</td>\n",
|
||||
" <td>Crotone</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>Cagliari</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>375</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Sassuolo</td>\n",
|
||||
" <td>Lazio</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>376</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Atalanta</td>\n",
|
||||
" <td>Milan</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>377</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Torino</td>\n",
|
||||
" <td>Benevento</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>378</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Bologna</td>\n",
|
||||
" <td>Juventus</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>379</th>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>Napoli</td>\n",
|
||||
" <td>Verona</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>380 rows × 3 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" matchday team1 team2\n",
|
||||
"0 1 Fiorentina Torino\n",
|
||||
"1 1 Verona Roma\n",
|
||||
"2 1 Parma Napoli\n",
|
||||
"3 1 Genoa Crotone\n",
|
||||
"4 1 Sassuolo Cagliari\n",
|
||||
".. ... ... ...\n",
|
||||
"375 38 Sassuolo Lazio\n",
|
||||
"376 38 Atalanta Milan\n",
|
||||
"377 38 Torino Benevento\n",
|
||||
"378 38 Bologna Juventus\n",
|
||||
"379 38 Napoli Verona\n",
|
||||
"\n",
|
||||
"[380 rows x 3 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"cal_df = pd.read_excel('fantacalcio/season2021/seriea_calendar.xlsx')\n",
|
||||
"\n",
|
||||
"to_drop = list()\n",
|
||||
"\n",
|
||||
"for i in range(cal_df.shape[0]):\n",
|
||||
" if(not isinstance(cal_df['matchday'][i], int)):\n",
|
||||
" to_drop.append(i)\n",
|
||||
" \n",
|
||||
"cal_df = cal_df.drop(to_drop)\n",
|
||||
"\n",
|
||||
"cal_df = cal_df.reset_index(drop = True)\n",
|
||||
"\n",
|
||||
"cal_df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "6d5d4101",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.DataFrame(columns = ['matchday', 'player', 'team', 'oppteam', 'home', 'vote', 'goals', 'assists', 'cards_malus', 'fantavote'])\n",
|
||||
"\n",
|
||||
"LAST_MATCH = 38\n",
|
||||
"\n",
|
||||
"for matchday in range(1, LAST_MATCH + 1):\n",
|
||||
" \n",
|
||||
" votes_file = 'fantacalcio/season2021/voti/Voti_Fantacalcio_Stagione_2020_21_Giornata_' + str(matchday) + '.xlsx'\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" rx = np.array(pd.read_excel(votes_file, header = None))\n",
|
||||
"\n",
|
||||
" read = 0\n",
|
||||
" for i in range(rx.shape[0]):\n",
|
||||
" if(rx[i, 0] == \"Cod.\"):\n",
|
||||
" read = 1\n",
|
||||
" team = rx[i-1, 0];\n",
|
||||
" continue\n",
|
||||
"\n",
|
||||
" if(read):\n",
|
||||
" if(isinstance(rx[i, 0], int)):\n",
|
||||
" if((isinstance(rx[i, 3], float) or isinstance(rx[i, 3], int)) and rx[i, 1] != \"ALL\") :\n",
|
||||
" player = rx[i, 2];\n",
|
||||
" vote = float(rx[i, 3])\n",
|
||||
" goals = rx[i, 4] + rx[i, 8] - rx[i, 5]\n",
|
||||
" assists = rx[i, 12]\n",
|
||||
" cards_malus = rx[i, 10] * 0.5 + rx[i, 11]\n",
|
||||
" \n",
|
||||
" oppteam = ''\n",
|
||||
" home = 0\n",
|
||||
" for j in range(cal_df.shape[0]):\n",
|
||||
" if(cal_df['matchday'][j] == matchday):\n",
|
||||
" if(cal_df['team1'][j] == team):\n",
|
||||
" oppteam = cal_df['team2'][j] \n",
|
||||
" home = 1\n",
|
||||
" elif(cal_df['team2'][j] == team):\n",
|
||||
" oppteam = cal_df['team1'][j] \n",
|
||||
" home = 0\n",
|
||||
"\n",
|
||||
" goals_gen = goals * 3;\n",
|
||||
" if(goals < 0):\n",
|
||||
" goals_gen = goals\n",
|
||||
" \n",
|
||||
" fantavote = vote + goals_gen + assists - cards_malus \n",
|
||||
" \n",
|
||||
" frame = pd.DataFrame([[matchday, player, team, oppteam, home, vote, goals, assists, cards_malus, fantavote]], columns = df.columns)\n",
|
||||
"\n",
|
||||
" df = pd.concat([df, frame], axis = 0, ignore_index = True)\n",
|
||||
" else:\n",
|
||||
" read = 0\n",
|
||||
" continue\n",
|
||||
"\n",
|
||||
" df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "0a4bbffd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.to_excel('mid_outputs/season2021/players_votes.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "48a341c2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user