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

Bug converting string to float in season_results() #40

Closed
Atiwat-R opened this issue Feb 4, 2025 · 1 comment
Closed

Bug converting string to float in season_results() #40

Atiwat-R opened this issue Feb 4, 2025 · 1 comment

Comments

@Atiwat-R
Copy link
Contributor

Atiwat-R commented Feb 4, 2025

Hello. I'm currently running into a bug while trying to use season_results()

ValueError: could not convert string to float: '168.33 57.9'

As of the date this issue is posted, I got the error after running this code.

from procyclingstats import Rider

rider = Rider("rider/tadej-pogacar")
data = rider.season_results()

After looking into the codebase and visiting the site the data is scraped from, I believe the problem is the way one of the data is entered in https://www.procyclingstats.com/rider/tadej-pogacar/

Image

Particularly, this part:

Image

I believe the code scrape this into a string '168.33 57.9' which, when attempted to convert to float in

if "distance" in fields:
    distances = table_parser.parse_extra_column("Distance", lambda x:
        float(x) if x.split(".")[0].isnumeric() else None)
    table_parser.extend_table("distance", distances)

in season_results(self, *args: str) of rider_scraper.py, results in conversion error.

Currently I'm thinking of fixing the issue in my project with something like

data = '168.33 57.9'.split(' ')[-1]

Or just modify it so it'd return string instead of float.

But I'm not very familiar with procyclingstats.com, so I'm not sure how frequent the data entered cross-out is, or if it will potentially also be done to fields elsewhere.

What do you think? I'm also interested to do a pull request, but i want to discuss the issue here first.

themm1 added a commit that referenced this issue Feb 10, 2025
Fix issue #40 and weight/height mislabel bug
@themm1 themm1 closed this as completed Feb 10, 2025
@themm1
Copy link
Owner

themm1 commented Feb 10, 2025

I couln't repeat this problem when testing on my device. They probably fixed the layout so that it works fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants