嗨,我有一个如下所示的数据集,存储为熊猫数据框(df)
device_id domain date event product_label event Product_label1
11 Amazon 24112017 basket view TV
12 Tesco 30122017 basket view Coffe
15 Costco 20092018 basket view Clothes
我尝试使用无法呈现正确格式的熊猫的堆栈函数df.stack()
下面是我要重塑数据的格式,
device_id domain date event product_label
11 Amazon 24112017 basket
11 Amazon 24112017 view TV
12 Tesco 30122017 basket
12 Tesco 30122017 view Coffe
请参阅以下堆栈溢出也不适用于上述问题 Python Pandas Wide to Long Format Change with Column Titles Spliting