ValueError: setting an array element with a sequence

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

This Python code:

import numpy as p

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


        
8条回答
  •  梦谈多话
    2020-11-22 06:34

    In my case, the problem was with a scatterplot of a dataframe X[]:

    ax.scatter(X[:,0],X[:,1],c=colors,    
           cmap=CMAP, edgecolor='k', s=40)  #c=y[:,0],
    
    #ValueError: setting an array element with a sequence.
    #Fix with .toarray():
    colors = 'br'
    y = label_binarize(y, classes=['Irrelevant','Relevant'])
    ax.scatter(X[:,0].toarray(),X[:,1].toarray(),c=colors,   
           cmap=CMAP, edgecolor='k', s=40)
    

提交回复
热议问题