Python Forum
Reading values into df.loc
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading values into df.loc
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib help with reading values from CSV file cps13 6 7,231 Aug-22-2017, 10:21 AM
Last Post: andre

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020