mardi 16 avril 2019

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

I am running the following chunk of code. Firstly I create a table called 'a' (This info is for context for the second part of the code)

a= doc.add_table(rows=3, cols=3)
# populate header row --------
heading_cells = a.rows[0].cells
heading_cells[0].text = 'A'
heading_cells[1].text = 'B'
heading_cells[2].text = 'C'


Then I am running the following IF statement on a column in the dataframe.



if df.loc[df.loc[:,'Hello'] =='A']:
    print (df.loc[:,'Line'], + "\n Placeholder A  \nPlaceholder B \n" + (a))
else:
    print (df.loc[:,'Line'] + "\n Placeholder A  n\Placeholder B \n")


I'm not getting any syntax errors, only the error message shown above.Any ideas as to where I may be going wrong?

Aucun commentaire:

Enregistrer un commentaire