-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvscode_snippets_python.json
More file actions
84 lines (72 loc) · 2.5 KB
/
vscode_snippets_python.json
File metadata and controls
84 lines (72 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{
// This file contains snippets in the VS Code format. You can paste them into the python.json file as part of user snippets.
// Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted.
// Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Imports": {
"prefix": "import_usefuls",
"body": [
"import os",
"import sys",
"from glob import glob",
"import numpy as np",
"import pandas as pd",
"pd.set_option('display.max_rows', 300)",
"pd.set_option('max_colwidth', 300)",
"from tqdm import tqdm",
"import hvplot.pandas",
],
"description": "Import useful packages"
},
"Pandas loader": {
"prefix": "train_test_load",
"body": [
"${1|train,test|} = pd.read_csv('./input/${2|train,test|}.csv",
],
"description": "Import useful packages"
},
"Memory checker": {
"prefix": "memory_usage",
"body": [
"import sys",
"ipython_vars = ['In', 'Out', 'exit', 'quit', 'get_ipython', 'ipython_vars']",
"sorted([(x, sys.getsizeof(globals().get(x))) for x in dir() if not",
" x.startswith('_') and x not in sys.modules and x",
" not in ipython_vars], key=lambda x: x[1], reverse=True)",
],
"description": "Get memory usage for variables"
},
"Dask bag": {
"prefix": "dask_bag",
"body": [
"from dask import bag, diagnostics",
"${1:dimsbag} = bag.from_sequence(${2:dimslist}).map(${0:get_dims_function})",
"with diagnostics.ProgressBar():",
" dims = dimsbag.compute()",
],
"description": "Parallelize function with dask bag"
},
// Requires dfmaxreduce.py and blank __init__.py in source directory
"Memory Reducer": {
"prefix": "maxreduce",
"body": [
"# Requires dfmaxreduce.py and blank__init__.py in sys.path dir",
"sys.path.append(${1:'D:/Dropbox (Personal)/Kaggles/molecules/}code/utils')",
"from dfmaxreduce import Maxreducer",
"reducer=Maxreducer()",
"${2:traintest} = reducer.reduce(${0:traintest}, verbose=True)",
],
"description": "Reduce memory footprint for pandas dataframes"
},
}