Iterate through Pandas throughs error only in Spyder
See original GitHub issueDescription
What steps will reproduce the problem?
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(4,3),columns = [‘col1’,‘col2’,‘col3’])
for row in df.itertuples(): File “<ipython-input-29-80c0315d0c1a>”, line 1 for row in df.itertuples(): ^ SyntaxError: unexpected EOF while parsing
whenever I try to iterate through a pandas dataframe I get an "unexpected EOF while parsing. This does not occur with other Python IDEs.
Versions
- Spyder version: 3.3.6
- Python version: 3.7.4
- Qt version: 5.9.6
- PyQt5 version: 5.9.2
- Operating System: Windows 10
Dependencies
pyflakes >=0.6.0 : 2.1.1 (OK)
pycodestyle >=2.3 : 2.5.0 (OK)
pygments >=2.0 : 2.4.2 (OK)
sphinx >=0.6.6 : 2.2.0 (OK)
rope >=0.9.4 : 0.14.0 (OK)
jedi >=0.9.0 : 0.15.1 (OK)
nbconvert >=4.0 : 5.6.0 (OK)
pandas >=0.13.1 : 0.25.1 (OK)
numpy >=1.7 : 1.16.5 (OK)
sympy >=0.7.3 : 1.4 (OK)
cython >=0.21 : 0.29.13 (OK)
qtconsole >=4.2.0 : 4.5.5 (OK)
IPython >=4.0 : 7.8.0 (OK)
matplotlib >=2.0.0: 3.1.1 (OK)
pylint >=0.25 : 2.4.2 (OK)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to iterate over rows in a DataFrame in Pandas
Answer: DON'T * ! Iteration in Pandas is an anti-pattern and is something you should only do when you have exhausted every other...
Read more >How to iterate over DataFrame rows (and should you?)
How to iterate over a pandas DataFrame is a common question, but understanding how to do it and when to avoid it are...
Read more >How to iterate over rows in Pandas: Most efficient options
This error occurs because each item in our iterrows() generator is a tuple-type object with two values, the row index and the row...
Read more >KeyError Pandas – How To Fix - Data Independent
Pandas KeyError - This annoying error means that Pandas can not find your column name in your dataframe. Here's how to fix this...
Read more >Using Pandas to Read Large Excel Files in Python
What happens? You should see a “File Not Loaded Completely” error since Excel can only handle one million rows at a time. We...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @rjudgeGit please take a look at this issue #12469, maybe this can help.
@rjudgeGit Your code is incomplete, there should be something after the
for
statement. How do you run the code? You have to make sure you run the loop in its entirety.