dimanche 17 novembre 2019

If else condition to compare 2 columns and insert a new column in Python pandas dataframe

I want to compare 2 columns using the following if else condition and update a value in the new column using some formula.

if df.loc[df['TF'] < df['PV']]:
    df['Par_2']] = 0.01*(1.8 * df['PV'] + 32) - 2
elif(some other condition)

While I execute this I get the following error

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

Can any one help what can I do to resolve this error. Or is there any other way to compare 2 columns and insert a new column whose value is calculation involving some other columns as shown above.

Aucun commentaire:

Enregistrer un commentaire