Skip to content

Instantly share code, notes, and snippets.

View sojournerd's full-sized avatar
std::coffee?

iman sojournerd

std::coffee?
View GitHub Profile
@sojournerd
sojournerd / gist:b866a4abae680d3e8e275b9cdfe06ccb
Created November 6, 2024 04:35 — 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])