#🔒 ValueError: invalid literal for int() with base 10: 'Scores' using pandas
26 messages · Page 1 of 1 (latest)
@rain linden
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
give the full thing
?
score_pd = pd.read_csv(score_doc, header=None, delimiter='[,]')
Traceback (most recent call last):
File "c:\Users*\OneDrive\Documents\2-pro\études\2-KIT Bachelor\VORLESUNGEN\Semester I\4-Programieren und Algoritmen I\test.py", line
8, in <module>
score_pd['Scores'] = score_pd['Scores'].astype('int64')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\generic.py", line 6643, in astype
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\internals\managers.py", line 430, in astype
return self.apply(
^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\internals\managers.py", line 363, in apply
applied = getattr(b, f)(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\internals\blocks.py", line 758, in astype
new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\dtypes\astype.py", line 237, in astype_array_safe
new_values = astype_array(values, dtype, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\dtypes\astype.py", line 182, in astype_array
values = _astype_nansafe(values, dtype, copy=copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users*\miniconda3\envs\pua\Lib\site-packages\pandas\core\dtypes\astype.py", line 133, in _astype_nansafe
return arr.astype(dtype, copy=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'Scores'
PS C:\Users*****\OneDrive\Documents\2-pro\études\2-KIT Bachelor\VORLESUNGEN\Semester I\4-Programieren und Algoritmen I\projekt\pua_20242025_breakout_template>
if you mean the code its to big for the past
!code
also the error comes from the fact that you said there's no header
but there's a header
oh thanks
what should i put instead f none
because the header cant be the column names becauce it schould be integers
idk
what does it require
!d pandas.read_csv
pandas.read_csv(filepath_or_buffer, *, sep=<no_default>, delimiter=None, header='infer', names=<no_default>, index_col=None, usecols=None, dtype=None, engine=None, ...)```
Read a comma-separated values (csv) file into DataFrame.
Also supports optionally iterating or breaking of the file into chunks.
Additional help can be found in the online docs for [IO Tools](https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html).
remove the header=None and let it infer the header
oh yes it actually works thanks!!!
!close to close the post
!close
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.