I am trying to filter my pandas data frame such that it retains the rows where these rows had one of the top 2 values in any of the data frame's column.
Here is an example:
d = {'col1': [1, 2, 3, 0], 'col2': [4, 6, 5, 2],'col3':[9, 8 , 7, 3], 'col4':[1, 2, 1, 0]}
Then I want the output to be:
I have tried using .nlargest and looping through the columns, buts its a mission to merge dataframes. There must be a simpler way, that I am yet to learn. Any help or pointers welcome.

