-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
pandas.errors.IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer #30
Comments
Greetings, it may be 'cit/year' column is later created from the data set, any division by 0 could generate an error. Hope it helps. |
Tried replicating here but didn't get your output:
|
For now, a quick fix can be done by adding a |
I can replicate the error with this |
Thanks @kevinsmia1939 , found the issue. It seems there are references "from the future" (which I find weird), the following result from your keyword made the error to be raised: https://www.sciencedirect.com/science/article/abs/pii/S001623612302793X It is from 2024. This is messing up with the cit/year calculation. Let me fix that. |
input:
python sortgs.py --kw "recommender system survey" OR "recommentation system survey" --startyear 2021
output:
Loading next 10 results
Loading next 20 results
Loading next 30 results
Loading next 40 results
Loading next 50 results
Loading next 60 results
Loading next 70 results
Loading next 80 results
Loading next 90 results
Loading next 100 results
Traceback (most recent call last):
File "C:\Users\ktash\Downloads\sort-google-scholar-master\sort-google-scholar-master\sortgs.py", line 313, in
main()
File "C:\Users\ktash\Downloads\sort-google-scholar-master\sort-google-scholar-master\sortgs.py", line 285, in main
data['cit/year']=data['cit/year'].round(0).astype(int)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py", line 5815, in astype
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 418, in astype
return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py", line 327, in apply
applied = getattr(b, f)(**kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py", line 591, in astype
new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py", line 1309, in astype_array_safe
new_values = astype_array(values, dtype, copy=copy)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py", line 1257, in astype_array
values = astype_nansafe(values, dtype, copy=copy)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py", line 1168, in astype_nansafe
return astype_float_to_int_nansafe(arr, dtype, copy)
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\dtypes\cast.py", line 1213, in astype_float_to_int_nansafe
raise IntCastingNaNError(
pandas.errors.IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer
My OS is windows. I run code by anaconda.
Thank you.
The text was updated successfully, but these errors were encountered: