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

'float' object has no attribute 'split' #21

Open
asinofsky opened this issue Feb 27, 2022 · 7 comments
Open

'float' object has no attribute 'split' #21

asinofsky opened this issue Feb 27, 2022 · 7 comments

Comments

@asinofsky
Copy link

Hi,

I'm new to github and python, I tried to run

python -m src.create_ufc_data

from the root folder to scrape fresh data last week, and it worked successfully, but when I tried this week, it seems to scrape everything successfully but then when processing I get this error:

'float' object has no attribute 'split'

Here is more detail:

Getting fighter urls

Getting fighter names and details

Scraping all fighter names and links:
Progress: |██████████████████████████████████████████████████| 100.00% Complete
No new fighter data to scrape at the moment, loaded existing data from C:\Users<username>...\UFC-Predictions-master\data\fighter_details.csv.
elapsed seconds = 19.22
Starting Preprocessing

Reading Files
Drop columns that contain information not yet occurred
Renaming Columns
Traceback (most recent call last):
File "C:\Users<username>\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users<username>\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users<username>\Documents\repos\mma\UFC-Predictions-master\src\create_ufc_data.py", line 21, in
preprocessor.process_raw_data() # Preprocesses the raw data and saves the csv files in data folder
File "C:\Users<username>\Documents\repos\mma\UFC-Predictions-master\src\createdata\preprocess.py", line 34, in process_raw_data
self._rename_columns()
File "C:\Users<username>\Documents\repos\mma\UFC-Predictions-master\src\createdata\preprocess.py", line 115, in _rename_columns
self.fights[column + attempt_suffix] = self.fights[column].apply(
File "C:\Users<username>\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\series.py", line 4430, in apply
return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
File "C:\Users<username>\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\apply.py", line 1082, in apply
return self.apply_standard()
File "C:\Users<username>\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\apply.py", line 1137, in apply_standard
mapped = lib.map_infer(
File "pandas_libs\lib.pyx", line 2870, in pandas._libs.lib.map_infer
File "C:\Users<username>\Documents\repos\mma\UFC-Predictions-master\src\createdata\preprocess.py", line 116, in
lambda X: int(X.split("of")[1])
AttributeError: 'float' object has no attribute 'split'

@asinofsky
Copy link
Author

If I delete the data and rerun it, it seems to work, so I think it's only when there was existing fighter data etc. it was trying to use.

@asinofsky
Copy link
Author

asinofsky commented Mar 2, 2022 via email

@ojneto
Copy link

ojneto commented Mar 2, 2022

Yes, I'm using windows. I managed to run the command. However, the following error appears:

Creating fight data

Scraping links!
Scraping event and fight links:
Progress: |██████████████████████████████████████████████████| 100.00% Complete
Successfully scraped and saved event and fight links!

Now, scraping event and fight data!

Scraping data for 595 fights:
Progress: |--------------------------------------------------| 0.00% Complete

TypeError Traceback (most recent call last)
in
2 print("Creating fight data \n")
3 fight_data_scraper = FightDataScraper()
----> 4 fight_data_scraper.create_fight_data_csv() # Scrapes raw ufc fight data from website
5 print(f'elapsed seconds = {(time.time() - time_start):.2f}')

~\Documents\UFC-Predictions-master\UFC-Predictions-master\src\createdata\scrape_fight_data.py in create_fight_data_csv(self)
43 self._scrape_raw_fight_data(
44 all_events_and_fight_links,
---> 45 filepath=self.TOTAL_EVENT_AND_FIGHTS_PATH,
46 )
47 else:

~\Documents\UFC-Predictions-master\UFC-Predictions-master\src\createdata\scrape_fight_data.py in _scrape_raw_fight_data(self, event_and_fight_links, filepath)
77 print(f'File {filepath} already exists, overwriting.')
78
---> 79 total_stats = FightDataScraper._get_total_fight_stats(event_and_fight_links)
80 with open(filepath.as_posix(), "wb") as file:
81 file.write(bytes(self.HEADER, encoding="ascii", errors="ignore"))

~\Documents\UFC-Predictions-master\UFC-Predictions-master\src\createdata\scrape_fight_data.py in _get_total_fight_stats(cls, event_and_fight_links)
121 futures = []
122 for fight in fights:
--> 123 futures.append(executor.submit(FightDataScraper._get_fight_stats_task, self=cls, fight=fight, event_info=event_info))
124 for future in concurrent.futures.as_completed(futures):
125 fighter_stats = future.result()

TypeError: submit() got multiple values for argument 'self'

@asinofsky
Copy link
Author

asinofsky commented Mar 3, 2022 via email

@ojneto
Copy link

ojneto commented Mar 3, 2022

I thank your attention. Could you briefly describe how you managed to get the updated data?

@asinofsky
Copy link
Author

asinofsky commented Mar 3, 2022 via email

@ojneto
Copy link

ojneto commented Mar 3, 2022

I keep trying.
Thank you for your help.

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