1
Hello people I am using this database 'https://cdn.tse.jus.br/statica/sead/odsele/votaca_partido_munzona/votacao_partido_munzona_2020.zip' to work. I would like to create a new column in the dataframe to classify ideology.
df_vot = pd.read_csv('./Dados aula04/votacao_partido_munzona_2020_BRASIL.csv', sep = ';', encoding = 'latin1')
centro = ['AVANTE', 'MDB', 'PROS', 'PSDB', 'SOLIDARIEDADE']
direita = ['DC', 'DEM', 'NOVO', 'PATRIOTA', 'PL', 'PMB', 'PMB', 'PODE', 'PP',
'REPUBLICANOS', 'PRTB', 'PSC', 'PSD', 'PSL', 'PTB', 'PTC']
esquerda = ['PC do B', 'PDT', 'PMN', 'CIDADANIA', 'PSB', 'PSOL', 'PT', 'PV', 'REDE']
for v in df_vot['SG_PARTIDO']:
if v in centro:
df_vot['IDEOLOGIA'] == 'Centro'
elif v in direita:
df_vot['IDEOLOGIA'] == 'Direita'
else:
df_vot['IDEOLOGIA'] == 'Esquerda'
df_vot
However in the output I am getting, only the first if is 'working'. The output I am having is equal to the figure below. I hope you can help me.
Served perfect! Thank you very much
– Diogo Gouveia Jr
Good morning @Diogogouveiajr! What a great one it served! Big hug!
– lmonferrari