Python

Date

datetime.datetime.now().strftime("%Y-%m-%d")) #2019-07-18 datetime.datetime.strptime("2020-03-11", "%Y-%m-%d") #2019-07-18

Control structures

if not os.path.isfile(myfile): print("File does not exist") # Switch cases using a dict options = {"twist": "Y151,I6,Y9,Y151", "xt_hs": "Y150,I8,Y10,Y150"} mask = options[arg]

Basics

Main data structures my_list = [1,2,3] my_tuple = (1,2,3) # immutable my_dictinary = {1: "Monday", 2: "Tuesday"} include double arithmetics from __future__ import division Function def double_value(x): return 2 * x lambda x: 2 * x Indexing x[-2] # second last element OS info import os # get current working dir print("Current working dir : %s" % os.getcwd())

Pandas

Data slicing # get df.loc[:, 'col1':'colN'] Descriptive statistics

Plotting

Packages matplotlib pandas seaborn (https://seaborn.pydata.org/tutorial.html) Statistical plotting # create correation coefficient heat map with values sns.heatmap(corr, xticklabels=corr.columns, yticklabels=corr.columns, cmap='coolwarm', annot=True, fmt='f')