This file contains 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
"AC","AL","AP","AM","BA","CE","DF","ES","GO","MA","MT","MS","MG","PA","PB","PR","PE","PI","RJ","RN","RS","RO","RR","SC","SP","SE","TO" |
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 14 columns, instead of 2. in line 5.
This file contains 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
PERFIL_ELEITORADO,CONSULTA_CAND_2010,CONSULTA_CAND_2012,CONSULTA_CAND_2014,BEM_CANDIDATO,CONSULTA_LEGENDAS ,CONSULTA_VAGAS ,VOTACAO_CANDIDATO_MUN_ZONA_2012,VOTACAO_CANDIDATO_MUN_ZONA_2014,VOTACAO_PARTIDO_MUN_ZONA_2012,VOTACAO_PARTIDO_MUN_ZONA_2014,VOTO_SECAO ,DETALHE_VOTACAO_MUN_ZONA_2012,DETALHE_VOTACAO_MUN_ZONA_2014 | |
PERIODO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO,DATA_GERACAO | |
UF,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO,HORA_GERACAO | |
MUNICIPIO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO,ANO_ELEICAO | |
COD_MUNICIPIO_TSE,NUM_TURNO ,NUM_TURNO ,NUM_TURNO ,DESCRICAO_ELEICAO,NUM_TURNO,DESCRICAO_ELEICAO,NUM_TURNO,NUM_TURNO,NUM_TURNO,NUM_TURNO,NUM_TURNO,NUM_TURNO,NUM_TURNO | |
NR_ZONA,DESCRICAO_ELEI |
This file contains 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
def split_data_frame_list(df, | |
target_column, | |
output_type=float): | |
''' | |
Accepts a column with multiple types and splits list variables to several rows. | |
df: dataframe to split | |
target_column: the column containing the values to split | |
output_type: type of all outputs |
This file contains 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
def suffix(alist): | |
if not len(alist): | |
return [[]] | |
else: | |
return [alist] + suffix(alist[1:]) | |
def preffix(alist): | |
if not len(alist): |
This file contains 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
DROP TABLE IF EXISTS main; | |
CREATE EXTERNAL TABLE main ( | |
endTimeMillis BIGINT, | |
startTimeMillis BIGINT, | |
endTime STRING, | |
startTime STRING, | |
jams array<struct< | |
uuid: STRING, | |
pubMillis: BIGINT, |
This file contains 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
CREATE TABLE waze.polygons_geo | |
WITH ( | |
external_location = 's3://...', | |
format = 'Parquet') AS | |
WITH dataset AS ( | |
SELECT | |
polygons | |
FROM waze.polygons) | |
SELECT | |
pol.polygon, |
This file contains 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
SELECT | |
'{"type":"LineString", "coordinates":' || | |
'[' || array_join(transform(line, loc -> '[' || CAST(loc.x AS VARCHAR) || ',' || CAST(loc.y AS VARCHAR) || ']'), ',') || ']}' | |
FROM test.test |
This file contains 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
# update-function-code-aws-lambda.sh <function path> <lambda-function-name> | |
# make sure that the aws-cli is configured in the same region and with a user with permission | |
rm temp.zip | |
echo ------ Zipping -------- | |
cp $1 lambda_function.py | |
zip temp.zip lambda_function.py | |
rm lambda_function.py | |
echo ------ Updating Lambda ------ | |
aws lambda update-function-code --function-name $2 --zip-file "fileb://temp.zip" |
This file contains 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
-- Delete *.csv.metadata | |
-- aws s3 rm s3://... --recursive --exclude '*.csv' | |
CREATE EXTERNAL TABLE `osm_pems_ids`( | |
`osm_id` bigint COMMENT '', | |
`sensor_id` string COMMENT '', | |
`neigh_level` bigint COMMENT '') | |
ROW FORMAT SERDE | |
'org.apache.hadoop.hive.ql.io.orc.OrcSerde' | |
STORED AS INPUTFORMAT |
This file contains 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 boto3 | |
table_filter = 'temp-cap' | |
dynamo = boto3.client('dynamodb') | |
tables = dynamo.list_tables()['TableNames'] | |
tables = [t for t in tables if table_filter in t] | |
for t in tables: | |
try: | |
dynamo.delete_table(TableName=t) | |
except: | |
continue |
OlderNewer