I want to extract N pieces for each group, and one of the countermeasures. For example, when you want to extract the daily column and the top nth sales.
N from the beginning in the group
N from behind in the group
Sample code: Up to the top 3 in sales
newdf = df.sort_values(by=['date','Sales'], ascending=[True, False]).groupby('date').head(3)
Reference article: https://blog.shikoan.com/pandas-groupby-head/