I have following Dataframe df:
+----------+--------+---------+
| ID| text | count|
+----------+--------+---------+
| 3| word| 316|
| 3| work| 385|
| 3| want| 205|
| 3| cat| 251|
| 1| office| 343|
| 1| sky| 643|
| 1| going| 126|
| 2| home| 124|
| 2| school| 23|
| 2| sleep| 103|
//and so on
Now, for each ID, I want to only display the rows with the largest 2 counts and drop/hide the rest:
+----------+--------+---------+
| ID| text | count|
+----------+--------+---------+
| 3| word| 316|
| 3| work| 385|
| 1| office| 343|
| 1| sky| 643|
| 2| home| 124|
| 2| sleep| 103|
//and so on
How do we achieve this most efficiently?