Python Pandas error AttributeError DataFrame object has no attribute rows

0 votes

I am trying to print each entry of the dataframe separately. The dataframe is created by reading a csv file. This is the code I am using:

import pandas as pd

df = pd.read_csv(“/home/user/data1”)

for row in df.rows:
    print (row)

But I am getting this error:

AttributeError: 'DataFrame' object has no attribute 'rows'
Mar 28, 2019 in Python by Rishi
129,986 views

2 answers to this question.

0 votes

There is no attribute called “rows”. The right attribute to use is “iterrows”. Try this code

import pandas as pd

df = pd.read_csv(“/home/user/data1”)

for row in df.iterrows():
    print (row)

Hope it works!!

If you are a beginner and need to know more about Python, It's recommended to go for Python Certification course today.

Thanks!

answered Mar 28, 2019 by Shri
0 votes

Try this:

data=pd.read_csv('/your file name', delim_whitespace=True)

data.Number

answered Dec 10, 2020 by anonymous
• 82,880 points

Related Questions In Python

0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'mainloop'" python module turtle

Hey @Nagya, replace  wn.mainlopp() with turtle.mainloop() ...READ MORE

answered Jun 19, 2019 in Python by Faiza
6,437 views
+1 vote
3 answers

Python error "AttributeError: 'Turtle' object has no attribute 'Shape'"

Hey @Nagya, replace python.Shape("Square") with the following: python.shape("square") Python is case ...READ MORE

answered Jun 19, 2019 in Python by Faiza
20,987 views
0 votes
1 answer

Python error "AttributeError: 'str' object has no attribute 'casefold'"

Check your python version. Casefold is possible ...READ MORE

answered Jul 4, 2019 in Python by Yesha
5,743 views
0 votes
1 answer

Python error "AttributeError: '_Screen' object has no attribute 'onkeypress'"

Instead of  wn.onkeypress(go_up, "w") Try wn.onkey(go_uo, " ...READ MORE

answered Jul 5, 2019 in Python by Pooja
4,376 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,023 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,414 views
0 votes
1 answer

Python error "'str' object has no attribute 'turtle' in Python turtle"

There is a syntax error. Change the ...READ MORE

answered Jul 9, 2019 in Python by Pallavi
7,016 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,560 points
34,061 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP