In [22]:
%matplotlib inline
In [23]:
import datetime
In [24]:
import pandas as pd
In [25]:
councilman = pd.read_csv('../data/sequential_id.csv')
secreataries = pd.read_csv('../data/secretary-councilman.csv')
# sequencial dos vereadores de são paulo
sequencial = councilman.sequential_id.tolist()
sequencial.extend(secreataries.sequential_id.tolist())
In [36]:
df = pd.read_csv(
'/home/flavio/Downloads/bem_candidato_2016/bem_candidato_2016_SP.txt',
encoding='iso-8859-1', sep=';', decimal=',', thousands='.',
names=['DATA_GERACAO', 'HORA_GERACAO', 'ANO_ELEICAO',
'DESCRICAO_ELEICAO', 'UF', 'SQ_CAND', 'CD_TIPO_BEM', 'DS_TIPO_BEM',
'DETALHE_BEM', 'VALOR_BEM', 'DATA_ULTIMA_ATU', 'HORA_ULTIMA_ATU'],
usecols=['SQ_CAND', 'DS_TIPO_BEM', 'DETALHE_BEM', 'VALOR_BEM'],
index_col=False
)
In [37]:
df.head(10)
Out[37]:
In [38]:
df['VALOR_BEM'] = df.VALOR_BEM.astype(float)
In [39]:
df['election_year'] = 2016
In [40]:
df = df[df['SQ_CAND'].isin(sequencial)]
In [41]:
df.head(1)
Out[41]:
In [42]:
df = df.rename(columns={
'SQ_CAND': 'sequential_id',
'DS_TIPO_BEM': 'kind',
'DETALHE_BEM': 'description',
'VALOR_BEM': 'value',
})
In [43]:
today = datetime.date.today()
df.to_csv(f"../data/{today}-property.csv", index=False)
In [ ]: