Skip to content

Instantly share code, notes, and snippets.

View EricSchles's full-sized avatar

Eric Schles EricSchles

View GitHub Profile
from datetime import datetime, timedelta
from textwrap import dedent
from functor import my_function
# The DAG object; we'll need this to instantiate a DAG
from airflow import DAG
# Operators; we need this to operate!
from airflow.operators.bash import BashOperator
from pyspark.sql.functions import col
def groupby(df, columns):
sdf = df.to_spark()
_groups = sdf.select(*columns).distinct().collect()
_groups = [group.asDict() for group in _groups]
groups = []
for group in _groups:
tmp = []
for column in columns:
from tensorflow.keras import Model
import tensorflow as tf
import numpy as np
import pandas as pd
import random
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(
from tensorflow.keras import Model
import tensorflow as tf
import numpy as np
import pandas as pd
import random
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(
from tensorflow.keras import Model
import tensorflow as tf
import numpy as np
import pandas as pd
import random
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(
import tensorflow as tf
import numpy as np
import pandas as pd
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(
tf.random.normal([out_features, out_features]), name='w'
)
pyramid_sum = lambda n: (2*(n**2) - (2*n - 1))
@EricSchles
EricSchles / recursive_line_count.py
Created September 10, 2020 16:37
count the number of lines in your jupyter notebooks
from glob import glob
from json import load
def loc(nb):
cells = load(open(nb))["cells"]
return sum(len(c["source"]) for c in cells)
root_folder = "~"
summation = 0
for File in glob(root_folder+"/**/*.ipynb", recursive=True):
@EricSchles
EricSchles / twine_upload.sh
Created April 8, 2020 14:31
A little utility for uploading python package updates
python setup.py sdist bdist_wheel
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
python -m twine upload dist/*
import numpy as np
import pandas as pd
from sklearn import linear_model
from sklearn.model_selection import train_test_split
# In general for the way to do type hinting is very straight forward.
# simply don't instantiate the class to use it as a 'type'
# Here's a generic example: