0

I am trying to fetch a row from pandas dataframe based on a condition.

[
    {
        "id": "ee123-abc"
    }
]
df = pd.DataFrame.from_dict(data)
contract_num = 'ee123-abc'

if df.id.str.contains(contract_num).any():
    print(df[df.id == contract_num])
else:
    print("No matching contract numbers")

But am getting an error message that says

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

How can I address this isue?

vvazza
  • 421
  • 7
  • 21

0 Answers0