I wrote this script to create a specific variable that takes different values according to the number of reports. Count of Report is an integer column.
no_audit = df_bei_index['Count of Report'] == 0
few_audit = df_bei_index['Count of Report'] > 0 & df_bei_index['Count of Report'] < 30
col_list = ['Policy Index (ELEVATE)_score', 'Transparency Score']
for col in col_list:
df_bei_index[col+'_corrected'] = np.where(m1, df_bei_index['PDI_Average'], np.where(
m2, df_bei_index[col]*0.05 + df_bei_index['PDI_Average']*0.95
, df_bei_index[col]))
yet, when I run it, I get the following mistake:
> --------------------------------------------------------------------------- ValueError Traceback (most recent call
> last) <ipython-input-42-6fe73dad7759> in <module>()
> 41 no_audit = df_bei_index['Count of Report'] == 0
> 42 df_bei_index
> ---> 43 few_audit = df_bei_index[(df_bei_index['Count of Report'] > 0 & df_bei_index['Count of Report'] < 30)]
> 44
> 45
>
> ~\Anaconda3\lib\site-packages\pandas\core\generic.py in
> __nonzero__(self) 1574 raise ValueError("The truth value of a {0} is ambiguous. " 1575 "Use a.empty,
> a.bool(), a.item(), a.any() or a.all()."
> -> 1576 .format(self.__class__.__name__)) 1577 1578 __bool__ = __nonzero__
>
> ValueError: The truth value of a Series is ambiguous. Use a.empty,
> a.bool(), a.item(), a.any() or a.all().
I looked around and this error comes up when you use 'and' or 'or' instead of '&' or '|', but clearly this is not my case.
What is wrong the script?