Skip to content

Instantly share code, notes, and snippets.

View flolas's full-sized avatar
🧭

Felipe Lolas flolas

🧭
  • Santiago, Chile
View GitHub Profile
@flolas
flolas / Event.json
Created March 30, 2017 16:41
EventStreaming
{
context : {
session : <int>,
id: <int>
},
timestamp: <timestamp(6)>,
event: <str>,
subevent: <str>,
fields: [
{
FROM ubuntu
ENV LANGUAGE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LC_CTYPE en_US.UTF-8
ENV LC_MESSAGES en_US.UTF-8
ENV LC_ALL en_US.UTF-8
RUN apt update && \
@flolas
flolas / multiproc_trim.py
Created August 24, 2016 03:40
Multiprocessing Trim Rows Python
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# multiproc_trim.py
"""A program that reads integer values from a CSV file and writes out their
sums to another CSV file, using multiple processes if desired.
"""
import csv
import multiprocessing
import optparse
@flolas
flolas / bteq.py
Last active January 12, 2021 02:05
"""
Code that goes along with the Airflow tutorial located at:
https://github.com/airbnb/airflow/blob/master/airflow/example_dags/tutorial.py
"""
from airflow import DAG
from datetime import datetime, timedelta
from airflow.operators.docker_operator import DockerOperator
start = datetime.combine(datetime.today() - timedelta(2), datetime.min.time())
@flolas
flolas / unpack_pandas.py
Last active July 25, 2016 22:27
Unpack Pandas series to multiple Pandas series(unpacking cols)
def unpack_col(col_to_unpack, df_to_append = None, header = 'col', sep=',', na_value=''):
import pandas as pd
unpacked_cols = col_to_unpack.fillna(na_value).apply(lambda x: pd.Series(x.split(','))).fillna(na_value)
#add dynamic columns names based on # of rows and parameter header passed for prefix (header_#)
col_names = []
for i in unpacked_cols.columns:
col_names.append(header + '_' + str(i))
unpacked_cols.columns = col_names
if isinstance(df_to_append, pd.DataFrame):
#return df concatenated with previously unpacked columns