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 in Python by Rishi
6,428 views

1 answer 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)
answered Mar 28 by Shri

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() a ...READ MORE

answered Jun 19 in Python by Faiza
243 views
0 votes
1 answer

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 in Python by Faiza
951 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 in Python by Yesha
693 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, "w ...READ MORE

answered Jul 4 in Python by Pooja
437 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 330 views
+4 votes
6 answers
0 votes
1 answer
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,520 points
7,977 views