- Summing two counters
- Remove all contents under some directory
- Python Logging datetime formatter
- Numpy logical_and
- Python lambda function keep value of local variable
- matplotlib multiple figures and axes
- subplot in loop
- histogram given bins and weights
- savefig without X
- bar chart
- GNU Parallel run multiple commands
- GNU parallel working directory
- Bash iterate through array
- argparse action="store_true|false"
- Python subprocess
- datetime.strftime cheatsheet
- No such file or directory when subprocess
- memory_profiler line by line
- time_profiler line by line
- nosetest --nocapture
- multiprocessing
- allows shared object event custom object
- can only pickle top level functions, classmethods not good, alternative,
pathos
- nose assert_equal.self.maxDiff=None
os.path.splitextto get extension and name without extension- sort the array before using
itertools.groupby. ref
- Pandas read_csv skip bad lines: pass
error_bad_lines=False - nth group
Series.tolistDataFrame.iterrows- ith row in DataFrame:
DataFrame.iloc[i] - add column:
df.columns.tolist() + [something] df.rename(columns={'old': 'new', ...}, inplace=True)df.to_json(orient="records")df.equalsdf.valuesto get data array- filter rows by condition:
df[df.map(func) > 0] scipy.spatial.distance.cdistget distance matrix
- Optional argument
- Category palettes:
d3.scale.ordinal().domain([...]).range(d3.scale.category10().range()); - d3 time format:
d3.time.format("%Y-%m-%d") - added node label
- get file name
${variable%.*} - get extension
${filename##*.}
- undo merge:
git reset --hard sha - use better branch
- object file is empty