0
I’m writing a program in Python to automate one of my work routines.
But I came across a part where I can’t go on, look:
At this stage, I need to write a code that identifies the lowest value of columns 1, 3 and 5 in each row of the DataFrame
below, and when you find the lowest value, return the string contained in the next column, and in the same row, of the value found, and save it all in a second DataFrame
.
DataFrame
that I am using (pandas) as an example in this case is the following:
Link to the data: Data(google drive)
The expected result here would be a dataframe containing the following information:
4bio
expressa
4bio
4bio
4bio
4bio
But even searching for several days, I am far from my goal. So far, the most I could write, and it hasn’t worked by a long shot:
resultado = []
for i in df3:
if i == df3.min (axis = 1):
resultado.append(i)
I ask you to have a little understanding, it’s the first program I try to write, and I’m really caught up in this task.
Thank you so much.
If the data were in the form of text I would even respond, because it would only be the case of copying and pasting the data create a Dataframe and apply the solution. But as it is an image would have to write value after value, line after line to there then solve the problem.
– Augusto Vasques
Good afternoon Augusto. I tried to paste in table format but had lost formatting so I thought it would be easier as picture, I’m sorry I will try again:
– Alvaro Baraldi
vl_proposto_4bio distribuidor_4bio vl_proposto_expressa distribuidor_expressa vl_proposto_pfizer distribuidor_pfizer 50 4bio 70 expressa 50 Pfizer 80 4bio 40 expresses 80 Pfizer 30 4bio 50 expresses - Pfizer 1200 4bio 1300 expresses 1200 Pfizer 300 4bio 500 express 300 Pfizer 200 4bio 250 express - Pfizer
– Alvaro Baraldi
I have uploaded the data to the link: https://drive.google.com/file/d/1iVTxpYRru9A9QQQIfjXWe_lxSlnhny_o/view?usp=sharing I will include in the question.
– Alvaro Baraldi