[Python] ValueError: The truth value of a DataFrame is ambiguous. I'm already using the...

Discussão em 'Python' iniciado por Stack, Julho 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently trying to create a list of the columns that have a boolean-based column so that I can change the data from yes/no to 1/0 for data analysis. However, it is giving the ValueError that the DataFrame is ambiguous. The code below is what I am trying to run and is throwing an error.

    def ordtobin(df):
    uni_df=unistats(df)
    for col in uni_df:
    if uni_df.loc[(uni_df['Unique']==2) & (uni_df['Numeric']=='False')]:
    binary=[col]


    Snapshot of the dataframe that it is trying to parse

    Continue reading...

Compartilhe esta Página