I'm trying to group by Date column and then sort by 'OI' column and show top 2 rows:
top2 = df.groupby(['Date'],sort=False).apply(pd.DataFrame.nlargest,2,'OI')
First problem is that apply is very, very slow since I have a lot of groups. What would be a faster alternative? Also, how would I get just the second row sorted by 'OI', instead of the largest 2. Thanks in advance