Skip to content

Instantly share code, notes, and snippets.

@mannsi
mannsi / Pandas_Df_index_intersection.py
Last active August 9, 2017 13:01
Filter a pandas dataframe from the intersection of 2 dataframe indexes
import pandas as pd
df1 = pd.DataFrame(data=[1, 2, 3, 4], index=pd.Index([1, 2, 3, 4]))
df2 = pd.DataFrame(data=[3, 4, 5, 6], index=pd.Index([3, 4, 5, 6]))
df1_only_rows_with_index_in_df2 = df1[df1.index.isin(df2.index)]
@mannsi
mannsi / SlowSequentialTraining
Created March 13, 2017 14:06
Training of 500 sequential keras models. Slowly but surely the models take longer and longer to train
import numpy
import random
import time
from keras.models import Sequential
from keras.layers import Dense
def run():
""" Runs 500 Sequential networks on a random train/test set. Slows down after each nn iteration """
num_input_nodes = 12
@mannsi
mannsi / Latex_code_example
Last active March 10, 2017 10:26
Latex code example
\usepackage{listings}
\begin{lstlisting}[language=Python, caption=Caption below code, captionpos=b]
# The ugliest python code in history to show nesting etc
def function_name(p1, p2):
some_var = 0
for i in range(len(p1)):
some_var += p2[i]