Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ For full documentation, see https://firstcyclingapi.readthedocs.io/en/latest/.

| | Pos | Rider | Team | Time | UCI | Rider_ID | Rider_Country | Team_ID |
|---:|------:|:----------------------|:------------------------|:--------|------:|-----------:|:----------------|----------:|
| 0 | 01 | Mathieu van der Poel | Corendon - Circus | 6:28:18 | 500 | 16672 | NED | 13279 |
| 1 | 02 | Simon Clarke | EF Education First | + 00 | 400 | 568 | AUS | 13208 |
| 2 | 03 | Jakob Fuglsang | Astana Pro Team | + 00 | 325 | 264 | DEN | 13198 |
| 3 | 04 | Julian Alaphilippe | Deceuninck - Quick Step | + 00 | 275 | 12474 | FRA | 13206 |
| 4 | 05 | Maximilian Schachmann | Bora - Hansgrohe | + 00 | 225 | 16643 | GER | 13200 |
| 0 | 01 | van der Poel Mathieu | Corendon - Circus | 6:28:18 | 500 | 16672 | NED | 13279 |
| 1 | 02 | Clarke Simon | EF Education First | + 00 | 400 | 568 | AUS | 13208 |
| 2 | 03 | Fuglsang Jakob | Astana Pro Team | + 00 | 325 | 264 | DEN | 13198 |
| 3 | 04 | Alaphilippe Julian | Deceuninck - Quick Step | + 00 | 275 | 12474 | FRA | 13206 |
| 4 | 05 | Schachmann Maximilian | Bora - Hansgrohe | + 00 | 225 | 16643 | GER | 13200 |

**Rider Results:**
```python
Expand All @@ -39,13 +39,13 @@ For full documentation, see https://firstcyclingapi.readthedocs.io/en/latest/.
>>> roglic.year_results(2020).results_df.head() # A pandas DataFrame of Roglic's 2020 results
```

| | Date | Pos | GC | Race | CAT | UCI | Unnamed: 7 | Race_ID | Race_Country |
|---:|-------:|:------|-----:|:---------------------|:------|------:|:-------------|----------:|:---------------|
| 0 | 9.08 | 1 | nan | Tour de l'Ain | 2.1 | 125 | Show more | 63 | FRA |
| 1 | 16.08 | DNF | nan | Criterium Dauphine | 2.WT1 | nan | Show more | 15 | FRA |
| 2 | 28.06 | 2 | nan | CN Slovenia ITT | CN | 30 | nan | 2128 | SLO |
| 3 | 21.06 | 1 | nan | CN Slovenia RR | CN | 100 | nan | 2127 | SLO |
| 4 | 4.1 | 1 | nan | Liege-Bastogne-Liege | 1.WT1 | 500 | Show more | 11 | BEL |
| | Date | Pos | GC | Race_Country | Race | CAT | UCI | Unnamed: 8 | Race_ID |
|---:|-------:|------:|-----:|:---------------|:----------------------|:------|------:|:-------------|----------:|
| 0 | 8.11 | 1 | nan | ESP | Vuelta a España | 2.UWT | 850 | Show more | 23 |
| 1 | 4.1 | 1 | nan | BEL | Liège-Bastogne-Liège | 1.UWT | 500 | Show more | 11 |
| 2 | 20.09 | 2 | nan | FRA | Tour de France | 2.UWT | 800 | Show more | 17 |
| 3 | 27.09 | 6 | nan | UCI | World Championship RR | WCRR | 225 | Show more | 26 |
| 4 | 9.08 | 1 | nan | FRA | Tour de l'Ain | 2.1 | 125 | Show more | 63 |

**Rankings Pages:**
```python
Expand Down
2 changes: 1 addition & 1 deletion first_cycling_api/race/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--------
>>> RaceEdition(race_id=9, year=2019).results().results_table.iloc[0]
Pos 01
Rider Mathieu van der Poel
Rider van der Poel Mathieu
Team Corendon - Circus
Time 6:28:18
UCI 500.0
Expand Down
18 changes: 9 additions & 9 deletions first_cycling_api/rider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
Examples
--------
>>> Rider(18655).year_results(2020).results_df.iloc[0]
Date 9.08
Pos 1
GC NaN
Race Tour de l'Ain
CAT 2.1
UCI 125.0
Unnamed: 7 Show more
Race_ID 63
Race_Country FRA
Date 8.11
Pos 1
GC NaN
Race_Country ESP
Race Vuelta a España
CAT 2.UWT
UCI 850.0
Unnamed: 8 Show more
Race_ID 23
Name: 0, dtype: object

"""
Expand Down
32 changes: 6 additions & 26 deletions first_cycling_api/rider/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,7 @@ def _get_header_details(self):
self.header_details['twitter_handle'] = link_to_twitter_handle(self.soup.find('p', {'class': 'left'}).a) if self.soup.find('p', {'class': 'left'}) and self.soup.find('p', {'class': 'left'}).a else None

def _get_sidebar_details(self):
# Find table with rider details on right sidebar
details_table = self.soup.find('table', {'class': 'tablesorter'})
details_df = pd.read_html(str(details_table))[0]
details = pd.Series(details_df.set_index('Information')['Information.1'])

# Load details from table into attributes
self.sidebar_details = {}
self.sidebar_details['nation'] = details['Nationality']
self.sidebar_details['date_of_birth'] = parse_date(details['Born'].rsplit(maxsplit=1)[0]) if 'Born' in details else None
self.sidebar_details['height'] = float(details['Height'].rsplit(maxsplit=1)[0]) if 'Height' in details else None
self.sidebar_details['WT_wins'] = int(details['WorldTour'].split()[0]) if 'WorldTour' in details else 0
self.sidebar_details['UCI_wins'] = int(details['UCI'].split()[0]) if 'UCI' in details else 0
self.sidebar_details['UCI_rank'] = int(details['UCI Ranking']) if 'UCI Ranking' in details else None
self.sidebar_details['agency'] = details['Agency'] if 'Agency' in details else None

# Load rider's strengths from details table
if 'Strengths' in details:
tr = details_table.find_all('tr')[-1]
td = tr.find_all('td')[1]
self.sidebar_details['strengths'] = [x.strip() for x in td if isinstance(x, bs4.element.NavigableString)]
else:
self.sidebar_details['strengths'] = []


class RiderYearResults(RiderEndpoint):
Expand Down Expand Up @@ -93,13 +72,14 @@ def _get_year_details(self):
self.year_details['Team Country'] = img_to_country_code(span.img)
self.year_details['Division'] = span.text.split('(')[1].split(')')[0]
elif 'Ranking' in span.text:
self.year_details['UCI Ranking'] = int(span.text.split(': ')[1])
self.year_details['UCI Ranking'] = int(span.text.split(': ')[1].split()[0])
self.year_details['UCI Points'] = float(span.text.split('(')[1].split('pts')[0])
elif 'Wins' in span.text:
self.year_details['UCI Wins'] = int(span.text.split(': ')[1])
elif 'Racedays' in span.text:
self.year_details['Race days'] = int(span.text.split(': ')[1])
self.year_details['UCI Wins'] = int(span.text.split(': ')[-1])
elif 'Race days' in span.text:
self.year_details['Race days'] = int(span.text.split(': ')[-1])
elif 'Distance' in span.text:
self.year_details['Distance'] = int(span.text.split(': ')[1].replace('.', '').split('km')[0])
self.year_details['Distance'] = int(span.text.split(': ')[-1].replace('.', '').split('km')[0])


def _get_year_results(self):
Expand Down