0

i have loaded a csv file as a dataframe using pandas. it has the headers as follows:

account_key status join_date cancel_date days_to_cancel is_udacity is_canceled

under these headers, values are stored in the dataframe.

i am iterating a for-loop over the dataframe(named enrollment) to print out the data row by row

for i in enrollments:
    print(i)

the above code should print out the values row by row. however the only output i'm getting is:

account_key
status
join_date
cancel_date
days_to_cancel
is_udacity
is_canceled

why is this happening? i am using jupyter notebook on windows

laxman prasad
  • 21
  • 1
  • 4
  • 1
    Because you need to use [`iterrows`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iterrows.html). Otherwise you just get the `columns`. And then consider that pandas really isn't suited to iterations; it has a whole other set of methods that try to make it more efficient and iterating is usually not a good idea. – roganjosh Jul 01 '19 at 18:29
  • Please, post complete code that works as you described. My crystal ball is out of order. ;-) – teroi Jul 01 '19 at 18:31

1 Answers1

0
for i, row in df.iterrows():
  print(row)
123
  • 595
  • 6
  • 18