I'm trying to identify when a "date" (been converted to an integer for this) is greater than 30, and if so, if there is another date for that individual that has a frequency of greater than 1 (at least 2) and if these are true I want to put the "top" date (the one that appeared the most of times) into a new column, but I'm running into an error.
for index_label, row_series in describe_crt.iterrows():
if (describe_crt["delta_days_post_crt"] != 0) & (describe_crt["delta_days_post_crt"] > 30) & (describe_crt["freq"] > 1):
describe_crt.at[index_label , "best_crt_date"] = describe_crt["top"]```
> ValueError Traceback (most recent call
> last) <ipython-input-108-9cc36c985dca> in <module>
> 7 # iterate over the dataframe row by row
> 8 for index_label, row_series in describe_crt.iterrows():
> ----> 9 if (describe_crt["delta_days_post_crt"] != 0) & (describe_crt["delta_days_post_crt"] > 30) & (describe_crt["freq"] >
> 1):
> 10 describe_crt.at[index_label , "best_crt_date"] = describe_crt["top"]
> 11
>
> ~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py in
> __nonzero__(self) 1553 "The truth value of a {0} is ambiguous. " 1554 "Use a.empty, a.bool(), a.item(),
> a.any() or a.all().".format(
> -> 1555 self.__class__.__name__ 1556 ) 1557 )
>
> ValueError: The truth value of a Series is ambiguous. Use a.empty,
> a.bool(), a.item(), a.any() or a.all().