Click here to Skip to main content
15,897,718 members

Comments by A v Nov2021 (Top 9 by date)

A v Nov2021 2-Jun-22 9:12am View    
Can you help me solve this
A v Nov2021 2-Jun-22 9:07am View    
Thank you! But your code does not eliminate anything in the first pass
A v Nov2021 2-Jun-22 8:53am View    
will modify the question in a application perspective for better clarity. Sorry for my bad presentation skills.

Lets say this is our dataframe df =pd.DataFrame({'resources'[100,200,300,300,400,400,400,500,1000],'score': [1,2,1,2,3,5,6,8,9]})

I want to find a trade-off with resources i use and my score. My priority is to get the best score with less resources. I iterate all combinations and see if a row is eligible to be considered. So basically in this 9 rows, rows 3, 4, 5,6 should be eliminated 3 because 1 gives the same score with less resource, 4 because 2 gives the same score with less resource, 5 and 6 because 7 gives a better score with same resource. I hope this will make my problem more clear
A v Nov2021 2-Jun-22 5:05am View    
I cannot find the libraries that help me do it. How do I loop through and drop?
df = pd.DataFrame({'A': [1,4,4,3,7],
'B': [1,2,2,6,4],
'C ': range(10, 5, -1)})
df2= df.drop(df[(df['A'] < df['A']) & (df['B'] > df['B'])].index)

This code does not work for me.
A v Nov2021 2-Jun-22 4:34am View    
I do not have a code. I don't know how to implement this logic in python. I start with the first row and check all other rows if there is a higher A value "AND" lower B value, if this is not satisfied I dont drop that row. Here, for the first row there are higher A value but no value is lower than the 1 in B so it should not be dropped. Likewise, iterate all rows.

When doing like this row 4 is dropped because it can see there are higher values than 3 in A and lower values than 6 in B .