Consider the following Pandas data frame.
import pandas as pd df = pd.DataFrame({"val":[1, 2, 3, 10, 20, 30, 40], "group_id&quo