Starting Vim
vim [file1] [file2] ...
| # example output | |
| # __main__ - WARNING - This is a warning | |
| # __main__ - ERROR - This is an error | |
| import logging | |
| # Create a custom logger | |
| logger = logging.getLogger(__name__) | |
| # Create handlers |
| grouped_df = data.groupby('col') | |
| num_subplots = grouped_df.ngroups | |
| fig_corr = plt.figure(figsize=(15, 250)) | |
| count = 0 | |
| for name, group in grouped_df: | |
| # limit by n of observations in a group | |
| if group.shape[0] >= 100: | |
| count = count + 1 | |
| ax_corr = fig_corr.add_subplot(round(num_subplots/3) + 1, 3, count) |
| # source: https://realpython.com/primer-on-python-decorators/ | |
| # This formula is a good boilerplate template for building more complex decorators. | |
| import functools | |
| def decorator(func): | |
| @functools.wraps(func) | |
| def wrapper_decorator(*args, **kwargs): | |
| # Do something before | |
| value = func(*args, **kwargs) | |
| # Do something after |
| from sklearn.metrics import r2_score, mean_squared_error | |
| import matplotlib.lines as mlines | |
| import matplotlib.transforms as mtransforms | |
| def stats(value, pred): | |
| res = [ | |
| { | |
| 'metric': 'R2', | |
| 'value' : r2_score(value, pred) | |
| } |
| import pandas as pd | |
| import mysql.connector.pooling | |
| start_cred = { | |
| 'db_user': <db_user>, | |
| ... | |
| } | |
| cnx = mysql.connector.pooling.MySQLConnectionPool(**start_cred) | |
| data = pd.read_csv('filename') |
| [user] | |
| name = <name> | |
| email = @gmail.com | |
| username = <username> | |
| [core] | |
| editor = vim | |
| whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol | |
| excludesfile = ~/.gitignore | |
| [web] | |
| browser = google-chrome |
| " Configuration file for vim | |
| " To customize it, copy to ~/.vimrc and edit! | |
| set nocompatible " Use Vim defaults (much better!) | |
| set bs=2 " allow backspacing over everything in insert mode | |
| set history=50 " keep 50 lines of command line history | |
| set textwidth=0 " Don't wrap words by default | |
| set ruler " Show the line and column numbers of the cursor |