I have a data frame like this,
df
col1 col2 col3 col4
1 3 4 2
4 6 7 7
3 6 3 3
Now I want to find out how many values are less than col4 values and store the count in another column, for example in first row there are 1 value less than 2 so the new value will be 1, the final data frame should look like,
col1 col2 col3 col4 col5
1 3 4 2 1
4 6 7 7 2
3 6 3 3 0
I could do this using a for loop by comparing the row values, but the execution time will be huge. I am looking for any pandas shortcut or any other method to do it most efficiently.