Python Forum
Reading values into df.loc - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Reading values into df.loc (/thread-20076.html)



Reading values into df.loc - silkpantsman - Jul-26-2019

Hi All,

First off I am very fresh to python and coding so apologies in advance.

I am trying to read values into a df.loc so that I can use an excel file to access the rows I want rather than manually typing them in each time. Currently, I have a basic line of code to change certain cells in a dataframe to another value.

df.loc[df.col1 == 'x', 'col2'] = 0
df.loc[df.col1 == 'y', 'col2'] = 0


I repeat this a bunch of times and currently, manually type in the cells in 'x'. Would it be possible to import values into x, y, z etc from another excel file?