0
df = pd.DataFrame()
df['col'] = [['a','b'], ['c', 'd']]
if not (['a', 'b'] in df.as_matrix(['col'])):
print("hello")
由於['a', 'b']
是在df.as_matrix(['col'])
,print(hello)
不應執行。但是,它是。if語句與熊貓as_matrix函數
我不明白爲什麼會出現這種情況。我如何編輯我的代碼,以便我的if語句不打印「hello」?
@JohnGalt這工作!如果您想發佈,我很樂意選擇您的答案作爲正確的答案。謝謝。 – PiccolMan