错误:系列的真值不明确。使用a.empty,a.bool(),a.item(),a.any()或a.all()

时间:2019-12-19 20:51:15

标签: python pyqt5

我在界面PYQT5中遇到以下错误

ValueError:系列的真值不明确。使用a.empty,a.bool(),a.item(),a.any()或a.all()。

出现错误的代码是

x = data.drop('DrainStatnumout',axis='columns')
                y = data['DrainStatnumout']

                data.Failuer = data.Failuer.astype(int)

                #xx = data.drop(['Assembly1_Availability','Assembly2_Availability',
                                #'LaserCutting_Availability','Failuer','DrainStatnumout'],axis='columns')
                #print(xx)

                X=pd.DataFrame(x)

                Y=pd.DataFrame(y)

                X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.20)


plt.figure()
            ax1 = sns.distplot(Y_predict)
            ax2 = sns.distplot(Y_test)
            plt.axvline(np.mean(Y_predict), color='b', linestyle='dashed', linewidth=5)
            plt.axvline(np.mean(Y_test), color='orange', linestyle='dashed', linewidth=5)

            #plt.savefig('dist1.png',dpi=200,orientation='portrait')
            plt.savefig('DecisionTreeClassifier2.png')


    ValueError                                Traceback (most recent call last)
    <ipython-input-1-e0a00ff7678b> in pushButton_2_handler(self)
        588         ax2 = sns.distplot(Y_test)
        589         plt.axvline(np.mean(Y_predict), color='b', linestyle='dashed', linewidth=5)
    --> 590         plt.axvline(np.mean(Y_test), color='orange', linestyle='dashed', linewidth=5)
        591         #plt.savefig('dist1.png',dpi=200,orientation='portrait')
        592         plt.savefig('DecisionTreeClassifier2.png')

任何输入表示赞赏

1 个答案:

答案 0 :(得分:0)

我取出了pd.data帧并解决了问题。

X = data.drop('DrainStatnumout',axis='columns')

Y = data['DrainStatnumout']
data.Failuer = data.Failuer.astype(int)




                X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.20)


plt.figure()
            ax1 = sns.distplot(Y_predict)
            ax2 = sns.distplot(Y_test)
            plt.axvline(np.mean(Y_predict), color='b', linestyle='dashed', linewidth=5)
            plt.axvline(np.mean(Y_test), color='orange', linestyle='dashed', linewidth=5)

            #plt.savefig('dist1.png',dpi=200,orientation='portrait')
            plt.savefig('DecisionTreeClassifier2.png')