0
不知道如何使用.bool(),任何,全部或空,使兩個不同的例子工作。每個拋出我的曖昧值誤差熊貓系列元素布爾檢查是模糊
import pandas as pd
first = pd.Series([1,0,0])
second = pd.Series([1,2,1])
number_df = pd.DataFrame({'first': first, 'second': second})
bool_df = pd.DataFrame({'testA': pd.Series([True, False, True]), 'testB': pd.Series([True, False, False])})
#ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
""" both the next two lines fail with the ambiguous Series issue"""
#each row should be true or false
bool_df['double_zero_check'] = (number_df['first'] != 0) and (number_df['second'] != 0)
bool_df['parity'] = bool_df['testA'] and bool_df['testB']