import importlib
import logging
import os
import numpy as np
import pandas as pd
if df['moderate_activity'] == 1:
print("Participates in Moderate Activity")
The log lists this after running my code:
self = 0 False
1 False
2 True
3 False
4 False
...
578 True
579 True
580 False
581 True
582 True
Name: moderate_activity, Length: 583, dtype: bool
def __nonzero__(self):
raise ValueError(
> f"The truth value of a {type(self).__name__} is ambiguous. "
"Use a.empty, a.bool(), a.item(), a.any() or a.all()."
)
E ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
The error references the first line, moderate_activity is binary. This is the first time I'm running into this error - I looked up a couple of solutions when trying to implement it in an if statement, such as changing if df['moderate_activity'] == 1:
to if df[df['moderate_activity'] == 1]:
but that didn't work. What could I do to fix this?