Skip to content

Instantly share code, notes, and snippets.

View CanoePaddle123's full-sized avatar

CanoePaddle123

View GitHub Profile
@CanoePaddle123
CanoePaddle123 / gist:a3f5eaacc460deb871913bd88b6d0d9d
Created February 21, 2018 01:19 — forked from why-not/gist:4582705
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])