Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Pandas printing out values of each cells

Tags:

python

pandas

I am trying to fetch values from an excel file using pandas dataframe and print out the values of each cells. Im using read_excel() to populate the dataframe, and I am looking for specific rows using the following line of code:

df.loc[df['Parcel_ID'] == parcel]

parcel being an arbitrary input from the user. And I simply use this to print out the cells:

row = df.loc[df['Parcel_ID'] == parcel]

print row['Category']
print row['Sub_Category']
.
.
(more values)

What I want is only the values from the cells, yet I get dtypes, names of the column, and other junks that I don't want to see. How would I only print out the value from each cells?

like image 961
Joseph Seung Jae Dollar Avatar asked Nov 19 '15 21:11

Joseph Seung Jae Dollar


1 Answers

If you have several values in your row you could use following:

row['Category'].values.tolist()
row['Sub_Category'].values.tolist()
like image 132
Anton Protopopov Avatar answered Sep 27 '22 23:09

Anton Protopopov