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 numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# Overwriting colab color scheme | |
sns.set_style("white") | |
def gen(n=40): | |
return np.random.normal(size=n) |
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 column_cleaner(df, inplace=False): | |
""" | |
Clean up column names where white spaces are trimmed and replaced. | |
All column names are lowercased for sanity. | |
""" | |
orig_cols = df.columns | |
new_cols = [] | |
for col in orig_cols: | |
new_cols.append("".join([c if c.isalnum() else "_" for c in col.strip()]).lower()) |
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 seaborn as sns | |
from scipy.optimize import curve_fit | |
# Function for linear fit | |
def func(x, a, b): | |
return a + b * x | |
# Seaborn conveniently provides the data for | |
# Anscombe's quartet. | |
df = sns.load_dataset("anscombe") |
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 colorsys | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
%matplotlib inline | |
def alter(alist, col, factor=1.1): | |
tmp = np.array(alist) | |
tmp[:,col] = tmp[:,col] * factor | |
tmp[tmp > 1] = 1 |