Skip to content
Advertisement

Manipulate string to drop columns on pandas

I’m trying to manipulate a list (type: string) to use that list to drop some columns from a dataframe. Dataframe

The list is from a dataframe that I created a condition to return columns whose sums of all values ​​are zero:

Selecting the columns with sum = 0

JavaScript

Importing the dataframe and turning it into a list:

JavaScript

Images from the list: List

Some itens from the list:

JavaScript

My goal is to transform the list so that I can drop the columns from that.

Transforming this list into this: "ABI - LETRAS", "ADMINISTRAÇÃO PÚBLICA", "AGRONOMIA", "ALIMENTOS", "ARQUIVOLOGIA", "AUTOMAÇÃO INDUSTRIAL"...

for this I made the following code (unsuccessful)

list_CO8 = ('"," '.join(CO8['Nulos'].apply(str.upper).tolist()))

Please, can anyone help me?

I’m trying to get:

JavaScript

To make: ex8_centro_oeste.drop(columns=[list])

Dataset link: Link for Drive (8kb)

Advertisement

Answer

I read your question properly only now. I deleted my previous answer. You want to drop all the columns that sums to zero, if I am not mistaken.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement