Skip to content

Instantly share code, notes, and snippets.

@sickdabig
sickdabig / .vimrc
Created January 4, 2023 08:10
vimrc configuration WSL2
set nocompatible
filetype off
set encoding=utf-8
call plug#begin('~/.vim/plugged')
Plug 'rust-lang/rust.vim'
Plug 'morhetz/gruvbox'
Plug 'itchyny/lightline.vim'
Plug 'preservim/tagbar'
@sickdabig
sickdabig / pairplot_seaborn.py
Created February 19, 2021 11:50
[scatter matrix / pair plot in seaborn] #plot #scatter #python #sns #pandas
#%% pairplot / scatter matrix
scatter_cols = ['tilt', 'pitch', 'DCAC ratio','IRR']
g = sns.pairplot(results.loc[:,scatter_cols + ['Simul.']], hue='Simul.',
x_vars=['IRR','tilt', 'pitch', 'DCAC ratio'],
y_vars=['IRR'],
)
g.fig.suptitle(site.Site,x=0.05, ha='left',va='top', fontsize=20)
handles = g._legend_data.values()
labels = g._legend_data.keys()
labels = g._legend.remove()
@sickdabig
sickdabig / lambda_if_else.py
Created May 12, 2020 10:59
[lambda if else] if else evaluation in lambda function #python #lambda
lambda x: True if x == 0 else False
@sickdabig
sickdabig / debug_in_jupyter
Created May 11, 2020 12:52
[debug in jupyter] set brake point in jupyter interactive mode #jupyter #python #debugging
from IPython.core.debugger import set_trace
set_trace()
@sickdabig
sickdabig / month_name_dict.py
Last active May 20, 2020 15:32
[dict of month'] create a dict for naming month #pandas #python #index
name = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Annual']
num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
dict(zip(num,name))
@sickdabig
sickdabig / rem_datelist_from_df.py
Created May 7, 2020 06:50
[remove dates from df] remove certain dates from a DataFrame #pandas #data #python
mask = ~np.in1d(df.index.date, pd.to_datetime(removelist).date)
df = df.loc[mask, :]
@sickdabig
sickdabig / mplt_tick_formater.py
Created April 30, 2020 14:41
[tick formater time and percent] format the axis ticks as time and percentage #python #matplotlib #plotting #figure
import matplotlib.dates as mdates
import matplotlib.ticker as mtick
ax.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))
ax.yaxis.set_major_formatter(mtick.PercentFormatter())
@sickdabig
sickdabig / notebooktohtmlnoinouts.bat
Created April 23, 2020 14:20
[nb to html no inputs] convert notebook to html without code inputs #python #jupyter #nbconvert #tohtml
jupyter nbconvert --no-input --to html notebook.ipynb
@sickdabig
sickdabig / readmultilevelcolumnnames.py
Last active April 21, 2020 12:57
[read multi level columns] read data with multi leveled column names into DataFrame #pandas #data #import #python
import pandas as pd
df = pd.read_csv("sample.csv", header=[0, 1], index_col=0, sep='\t')
# convert index if required
df.index = pd.to_datetime(df.index)
@sickdabig
sickdabig / pickle_with_open.py
Created April 15, 2020 06:50
[read/write to pickle] read and write a dataset to pickle using "with open" statement #python #pandas #data
import pickle
# write to file
with open("filename.pkl", "wb") as f:
pickle.dump(data, f)
# read from file
with open("filename.pkl", "rb") as f:
data = pickle.load(f)