pandoc file.md -o file.pdf
-
To count occurrences when aggregating (e.g. in
pivot_table
), uselen
asaggfunc
! -
To drop a row: Cheatsheet
df[df.name != 'Tina']
df.drop(df.index[2])
-
c['a'].shift(periods=1)
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
# defaultdict use case | |
# Finding a Pareto front, where (x1, x2) is a list of tuples satisfying | |
# e.g. (x1, x2) : |df[(df[var1 > x1]) & df[var2 > x2)]| < 0.1|df|, | |
# where |df| is the size of df, i.e., df.shape[0] (in Pandas) | |
pareto = defaultdict(lambda: np.Inf) | |
for x1, x2 in xs: | |
pareto[x1] = min(pareto[x1], x2) |
- Virtualenv & stuff (incl.
autoenv
): Read! - Homebrew
- LaTeX w/ Sublime
Requires node.js and npm.
First, do npm install -g ijavascript
.
Then run ijs
once.
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
plt.savefig(filename, bbox_inches='tight')
--> get the entire plot when saved- Reset to factory default
matplotlib
style
import matplotlib as mpl
mpl.rcParams.update(mpl.rcParamsDefault)
plt.axes('tight')
removes all space around the area of the curveplt.axes('equal')
ensures x-y evenplt.axhline(y=production_accuracy, linewidth=2, color='k', label='production')
horizontal line
- save:
C-x C-s
(+ enter) - open file:
C-x C-f
- switch to buffer:
C-x b
- meta key
M
is escape and left alt (option) C-k
: kills from cursor until end of lineC-/
(7) -- undo!C-a
start of lineC-e
start of lineM-f
forward one wordM-b
back one word
plot(x, y)
+abline(a, b, col="red", lwd=2)
plot(x, y, type="b", col="red", pch=19)
"dotdash" med filledplot(x, y, type="b", col="red")
"dotdash" uten filledrm(list=ls(all=TRUE))
remove stuff- `sapply(.., simplify='array') == unlist(lapply(..))