[Python] How to drop columns which have same values in all rows via pandas or spark dataframe?

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    Suppose I've data similar to following:

    index id name value value2 value3 data1 val5
    0 345 name1 1 99 23 3 66
    1 12 name2 1 99 23 2 66
    5 2 name6 1 99 23 7 66


    How can we drop all those columns like (value, value2, value3) where all rows have the same values, in one command or couple of commands using python?

    Consider we have many columns similar to value, value2, value3...value200.

    Output:

    index id name data1
    0 345 name1 3
    1 12 name2 2
    5 2 name6 7

    Continue reading...

Compartilhe esta Página