我有一个如下所示的数据框。我想找出从上周(202008 年)开始按国家和产品的连续周数下降。
import pandas as pd
raw_data = {'Country': ['UK','UK','UK','UK','UK','UK','UK','UK','UK','UK','UK','UK','US','US','UK','UK'],
'Product':['A','A','A','A','A','A','A','A','B','B','B','B','C','C','D','D'],
'Week': [202001,202002,202003,202004,202005,202006,202007,202008,202001,202006,202007,202008,202006,202008,202007,202008],
'Orders': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
df = pd.DataFrame(raw_data, columns = ['Country','Product','Week','Orders'])
df2 = df.pivot_table(index=['Country','Product'], columns='Week',values='Orders', aggfunc='size').reset_index()
我想在输出下面检查它从上周开始的连续数周它为空。
MYYA
相关分类