Category : for-loop

I have this function called error, which estimates value based on previous value and rewards in trials. The difference between the estimated value and true value is then calculated, giving the error. I need to run this code 1000 times with different lists of trials, but currently it runs too slowly. How would I optimize ..

Read more

I have a dataset with ‘Date’ and ‘Installs’, and I want to add a new column ‘Payout’. But the ‘Payout’ differs based on the ‘Date’ and ‘Installs. eg. 2021-04-09, 2 and in the ‘Payout’ column, should be $0.25 * 2 eg. 2021-04-22, 5 and in the ‘Payout’ column, should be $0.4 * 5 I have ..

Read more

I have 2 for loops, which I would like to modify with vectorization, since the 2 for loops take ages till they finish. The code I want to transform: for i in range(2345): for j in range(2345): if j == i: continue else: # From start = (dfGrid[‘Y_Centroid’].iloc[i], dfGrid[‘X_Centroid’].iloc[i]) # To end = (dfGrid[‘Y_Centroid’].iloc[j], dfGrid[‘X_Centroid’].iloc[j]) ..

Read more

Few cells of my dataframe have duplicates merged with a special character ||||. example: 20210319||||20210319, 63||||64.17, 14.26||||14.26 I am trying to check if a duplicate value is appended after the special character. if its a duplicate, i want to remove the duplicate value. if they are unique(eg : 63||||64.17), i want to keep it. I ..

Read more