ValueError: setting an array element with a sequence

后端 未结 8 1180
萌比男神i
萌比男神i 2020-11-22 05:46

This Python code:

import numpy as p

def firstfunction():
    UnFilteredDuringExSummaryOfMeansArray = []
    MeanOutputHeader=[\'TestID\',\'         


        
8条回答
  •  长发绾君心
    2020-11-22 06:17

    When the shape is not regular or the elements have different data types, the dtype argument passed to np.array only can be object.

    import numpy as np
    
    # arr1 = np.array([[10, 20.], [30], [40]], dtype=np.float32)  # error
    arr2 = np.array([[10, 20.], [30], [40]])  # OK, and the dtype is object
    arr3 = np.array([[10, 20.], 'hello'])     # OK, and the dtype is also object
    

    ``

提交回复
热议问题