sportowe_wizualizacja/538 LaLigaPredictions/ismatchday.py
Koushik R Kirugulige 67713adbda
Create ismatchday.py
file that weekly updates (cron job) the end of matchday dates from [fbref](http://fbref.com/)
2020-10-28 16:49:18 +05:30

31 lines
900 B
Python

#updates the LaLigaMatchday CSV file once every week
#!/usr/bin/env python
# coding: utf-8
import pandas as pd
import logging
logging.basicConfig(filename="MatchdayLaliga.log", format='%(asctime)s %(message)s', filemode='a')
url ='https://widgets.sports-reference.com/wg.fcgi?css=1&site=fb&url=%2Fen%2Fcomps%2F12%2Fschedule%2FLa-Liga-Scores-and-Fixtures&div=div_sched_ks_10731_1'
logger=logging.getLogger()
logger.setLevel(logging.DEBUG)
# In[2]:
df = pd.read_html(url,encoding = 'utf_8')[0]
df.drop_duplicates(inplace=True)
#display(df)
# In[3]:
idx =df.groupby(['Wk'], sort=False)['Date'].transform(max) == df['Date']
df_match_day = df.groupby(['Wk'], sort=False)['Date'].max().to_frame()
if df_match_day.empty == True:
logger.info("The returned DataFrame is empty")
# In[4]:
df_match_day.to_csv('LaLigaMatchday.csv',index=False)
logger.info("Successfully updated LaLigaMatchday.csv")