[Python] How to find if all the columns in a dataframe are object dtype?

Discussão em 'Python' iniciado por Stack, Dezembro 21, 2024.

  1. Stack

    Stack Membro Participativo

    Let's say I have a DataFrame as data, and I want to find if every single column in the data frame is an object and use it as an if condition.

    example:

    describe = data.describe
    (if condition to find all the columns are 'object'):
    agg = data.agg(['a','b','c'])
    if not agg.empty:
    describe = pd.concat(describe,agg)
    describe = describe.round(2)

    Continue reading...

Compartilhe esta Página