Python Forum
Code improvement: groupby and operation on conditionals
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code improvement: groupby and operation on conditionals
#7
I've found a solution for the final block of code, in order to set a 'floor' or minimum to the dataset from the table that was constructed previously.

for idx, row in df.iterrows():
    for analyte in ['compound1', 'compound2', 'compound3']:
        if df.loc[idx, analyte] < float(max_dict[row[0]][analyte]):
            df.loc[idx, analyte] = float(max_dict[row[0]][analyte])
Thank you for your help, perfringo!
Reply


Messages In This Thread
RE: Code improvement: groupby and operation on conditionals - by pythonidae - Dec-12-2019, 05:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pandas change row value an existing column with conditionals Gigux 1 2,947 Jun-22-2019, 08:04 PM
Last Post: Gigux
  Genetic Algorithm improvement Alberto 0 4,271 Oct-19-2017, 02:13 PM
Last Post: Alberto

Forum Jump:

User Panel Messages

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