First, sort the DataFrame and then all you need is groupby.diff() : df = df.sort_values(by=['site', 'country', 'date']) df['diff'] ...
確定! 回上一頁