Given
import pandas as pd df = pd.DataFrame({ "a": [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, ], }) print(df)