-
-
Save tarsisazevedo/7236cc19647fa9908e4205b7f391a19a to your computer and use it in GitHub Desktop.
limpeza-temer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
titles = ['Deputado Federal ', 'General ', 'Ex-presidente ', 'Senadora ', 'Senador ', 'do Exército', 'Tenente-Brigadeiro'] | |
novas_linhas = [] | |
for _, row in agenda2016_limpa_final.iterrows(): | |
nova_linha = [row["oque"], row["onde"], row["ano"], row["mes"], row["dia"], row["hora"]] | |
pessoas = [re.sub('|'.join(titles),'',i.split(', ')[0]) for i in row["oque"].split('; ')] | |
for pessoa in pessoas: | |
linha_com_pessoa = nova_linha[:] # o lista[:] eh para copiar a lista | |
linha_com_pessoa.append(pessoa) | |
novas_linhas.append(linha_com_pessoa) | |
novo_df = pd.DataFrame(novas_linhas, columns=["oque", "onde", "ano", "mes", "dia", "hora", "pessoa"]) |
Author
tarsisazevedo
commented
Feb 25, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment