[Solved] python Error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.

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

if (code in list(changed_code['Old material code'])):
            temp_index = changed_code.loc[changed_code['Old material code'] == code].index

The type of code here is float.

Cause analysis:

In this judgment method, the judged value cannot be of float type.

Solution:

Just convert float format to int format

if (int(code) in list(changed_code['Old material code'])):
            temp_index = changed_code.loc[changed_code['Old material code'] == code].index

Solve the problem, brothers, get better!!

Read More: