重塑熊猫数据框-唯一行错误

时间:2020-02-06 01:19:25

标签: python pandas reshape

我有一个如下数据框;

enter image description here

我正在尝试使用pandas包中的reshape函数,它不断给我以下错误

“ id变量需要唯一标识每一行”。 enter image description here

这是我要重塑的代码:

链接到数据:https://pastebin.com/GzujhX3d

GG_long=pd.wide_to_long(data_GG,stubnames='time_',i=['Customer', 'date'], j='Cons')

“客户”和“日期”的组合在我的数据中是唯一的行,因此我不明白为什么它会引发此错误以及如何解决该错误。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

我可以找出问题所在。该错误是由于两件事引起的:第一是列名中包含“:”,第二是日期格式,由于某种原因,它不喜欢dd-mm-yy,而是与dd / mm /一起使用yy。

相关问题