Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""Calculate a Confusion Matrix for multi-class classification
model results
2019 Colin Dietrich
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
@crdietrich
crdietrich / useful_pandas_snippets.py
Last active May 18, 2018 22:24 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
# -*- coding: utf-8 -*-
"""
Colors and markers for contrast plotting large numbers of series
Created on Fri Sep 2 10:31:04 2016
@author: Colin Dietrich
"""
import colorsys
from math import pi
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))