Show Menu
Cheatography

Python for excel (Finance focused) Cheat Sheet (DRAFT) by

Cheat sheet focused on finance work with Python for excel.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Pandas (Data Manipu­lation)

pd.Dat­aFr­ame()
Creates DataFrames from lists, dictio­naries, or external data.
df.loc[] and df.iloc[]:
Row and column indexing. As a note, iloc is easier to work with, as it calls the "­nam­e" of the columns.
df.gro­upby():
Data grouping by catego­ries.
df.piv­ot_­tab­le():
Creates pivot tables.
df.mer­ge():
Merges two DataFr­ames.
df.app­ly():
Applies custom functions to columns.
df['co­lum­n].r­ol­ling()
for Moving Windows (Rolling Statis­tics). Key arguments: window -> Number of periods | min_pe­riods -> min. observ­ations per window

Data Visual­ization

plt.pl­ot(). Plot lines
plt.bar(): Creates bar charts.
plt.hi­st(): Creates histog­rams.
plt.sc­att­er(): Creates scatter plots.
plt.sh­ow(): Displays the plot.
plt.ti­tle­("My Chart Title")
df.plo­t(k­ind­='i­nsert here whatever your fav chart is, i.e., bar, hist, scatter')