[Solved] How to transform given dataset in python? [closed]
From your expected result, it appears that each “group” is based on contiguous id values. For this, you can use the compare-cumsum-groupby pattern, and then use agg to get the min and max values. # Sample data. df = pd.DataFrame( {‘id’: [1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, … Read more