Skip to content

Instantly share code, notes, and snippets.


Benjamin Kaplan benjaminkaplanphd

View GitHub Profile
benjaminkaplanphd /
Created Sep 13, 2019
Print Theano Tensor Shape
import numpy as np
from theano import function, printing, shared, tensor as T
PRINT = printing.Print('Theano shape: ', attrs=['shape'])
def example():
array = np.ones((3, 4))
print(f'Numpy shape: {array.shape}')
benjaminkaplanphd /
Created Feb 6, 2019
Explode array values in columns to multiple rows
import numpy as np
import pandas as pd
def explode(frame: pd.DataFrame, columns: List[str]):
This helper function explodes a new row
for each value in an array of values.
If there is more than one column to be exploded,
the array lengths must be the same (row-wise)