Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggiunte operazioni di casting in alcune assegnazioni/confronti #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions Fantacalcio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
from tqdm import tqdm
import pandas as pd
from loguru import logger
import telebot
import datetime

API_TOKEN = 'inserisciapikey'
bot = telebot.TeleBot(API_TOKEN)

ruoli = ["Portieri", "Difensori", "Centrocampisti", "Trequartisti", "Attaccanti"]

Expand Down Expand Up @@ -178,7 +183,7 @@ def appetibilita(df: pd.DataFrame) -> float:
appetibilita = float(row[7]) * int(row[5]) / 38

# media pesata fantamedia * convenienza rispetto alla quotazione * media scorso anno
appetibilita=appetibilita*row['Punteggio']*30/100
appetibilita=appetibilita*float(row['Punteggio'])*30/100
if float(row[1]) == 0: pt=1
else: pt=float(row[1])
appetibilita = (
Expand All @@ -197,17 +202,17 @@ def appetibilita(df: pd.DataFrame) -> float:

if row["Nuovo acquisto"]:
appetibilita -= 2
if row["Buon investimento"] == 60:
if int(row["Buon investimento"]) == 60:
appetibilita += 3
if row["Consigliato prossima giornata"]:
appetibilita += 1
if row["Trend"] == "UP":
appetibilita += 2
if row["Infortunato"]:
appetibilita -= 1
if row["Resistenza infortuni"] > 60:
if int(row["Resistenza infortuni"]) > 60:
appetibilita += 4
if row["Resistenza infortuni"] == 60:
if int(row["Resistenza infortuni"]) == 60:
appetibilita += 2

res.append(appetibilita)
Expand Down Expand Up @@ -275,6 +280,14 @@ def appetibilita(df: pd.DataFrame) -> float:
]
df.sort_values(by="Convenienza", ascending=False)

# df.to_csv("giocatori_appet.csv", index=False)
df.to_excel("giocatori_excel.xls")
logger.debug("Finito!")
#df.to_json("resdasda.json")
#df.to_csv("giocatori_appet.csv", index=False)
x = datetime.datetime.now()
symb=[" ",".","-",":"]
for value in symb:
x=str(x).replace(value,"")
res="giocatori"+x+".xls"
df.to_excel(res)
doc = open(res, 'rb')
bot.send_document("inserisci_idchat_gruppo",doc)
logger.debug("Finito!")