ValueError: Shape of passed values is (6, 3), indices imply (6, 6)

他需要6列6行,但是只给了6列3行。

一般情况看看自己的创建dataframe是否有错误

pdd_annual_transaction_value = pd.DataFrame([[pdd_201701_201712[0], pdd_201704_201803[0],                     
                                            pdd_201707_201806[0], pdd_201710_201809[0], 
                                            pdd_201801_201812[0], pdd_201804_201903[0]],
                                            [pdd_201701_201712[1], pdd_201704_201803[1], 
                                            pdd_201707_201806[1], pdd_201710_201809[1], 
                                            pdd_201801_201812[1], pdd_201804_201903[1]],
                                            [pdd_201701_201712[2], pdd_201704_201803[2], 
                                            pdd_201707_201806[2], pdd_201710_201809[2], 
                                            pdd_201801_201812[2], pdd_201804_201903[2]]],
                                            index = ['201701_201712', '201704_201803', 
                                                     '201707_201806', '201710_201809', 
                                                     '201801_201812', '201804_201903'])

发现他需要六行,而我写错了,应该改成

pdd = pd.DataFrame([[pdd_201701_201712[0], pdd_201701_201712[1], pdd_201701_201712[2]],
                    [pdd_201704_201803[0], pdd_201704_201803[1], pdd_201704_201803[2]],
                    [pdd_201707_201806[0], pdd_201707_201806[1], pdd_201707_201806[2]],
                    [pdd_201710_201809[0], pdd_201710_201809[1], pdd_201710_201809[2]],
                    [pdd_201801_201812[0], pdd_201801_201812[1], pdd_201801_201812[2]],
                    [pdd_201804_201903[0], pdd_201804_201903[1], pdd_201804_201903[2]]],
                    index = ['201701_201712', '201704_201803', '201707_201806', 
                             '201710_201809', '201801_201812', '201804_201903'])

即可

你可能感兴趣的:(python,pandas,python,数据处理)