在阅读了其他一些关于这个主题的Stackoverflow文章之后,我想到了下面的代码,但是我不断地遇到错误。你知道吗
df6['Accepted'] = np.where((df6['Status'] == 'Admitted' or df6['Status'] ==
'Admitted from WL' or df6['Status'] == 'Matriculating'), '1', '0')
我也试着用以下代替“ors”:
df6['Status'] in ['Admitted' , 'Admitted from WL', 'Matriculating']
这也不管用
我不断得到以下错误:
Traceback (most recent call last):
File "<pyshell#52>", line 1, in <module>
exec(open("C:\\python\\xxxxxx\\Analysis\\clean_data_v6.py").read())
File "<string>", line 110, in <module>
File "C:\Users\xxxxxxx\AppData\Local\Programs\Python\Python35-32\lib\site
packages\pandas\core\generic.py", line 917, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(),
a.item(), a.any() or a.all().
我需要改变什么?你知道吗
而不是这样:
你需要这个:
或更简单:
相关问题 更多 >
编程相关推荐