梵蒂冈之花
df = pd.DataFrame({'start_date':['2020-09-21','2020-09-21','2020-09-28', '2020-09-28'], 'end_date':['2020-09-27', '2020-09-27', '2020-10-04', '2020-10-04'], 'Country':['Russia', 'India','Russia','India'], 'orders':[150,80,100,120]})df['start_date'] = pd.to_datetime(df['start_date'])df.sort_values(by='start_date', inplace=True)df['% Change'] = df.groupby('Country')['orders'].pct_change()输出 start_date end_date Country orders % Change0 2020-09-21 2020-09-27 Russia 150 NaN1 2020-09-21 2020-09-27 India 80 NaN2 2020-09-28 2020-10-04 Russia 100 -0.3333333 2020-09-28 2020-10-04 India 120 0.500000