ValueError: cannot copy sequence with size 5 to array axis with dimension 2

前端 未结 1 2563
刺人心
刺人心 2020-12-06 18:45

using numpy 1.7.1 the below code works and produces the result as shown,

import pandas as pd
import numpy as np
d1 = pd.DataFrame({\'Name\': [1, 1, 1, 1, 1],         


        
相关标签:
1条回答
  • 2020-12-06 19:07

    I was able to reproduce your issue with numpy 1.9.2. It seems that numpy is trying to do a vstack. when the shape are same. I tried the following approach and it worked.

    result = np.empty(2, dtype=object)
    result[:]= [d1, d2]
    
    result
    array([    Name  number
    0     1       1
    1     1       1
    2     1       1
    3     1       1
    4     1       1,
              Name  number
    0     1       1
    1     1       1
    2     1       1
    3     1       1
    4     1       1], dtype=object)
    
    0 讨论(0)
提交回复
热议问题