forked from qubitron/pydemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.json
More file actions
44 lines (44 loc) · 1.29 KB
/
Copy pathpython.json
File metadata and controls
44 lines (44 loc) · 1.29 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
{
// copy these snippets into %appdata%\code\user\snippets\python.json
"StackOverflow: download survey": {
"prefix": "sodownload",
"body": [
"import requests",
"data = requests.get('https://drive.google.com/uc?export=download&id=0B6ZlG_Eygdj-c1kzcmUxN05VUXM')",
"with open('survey2017.zip', 'wb') as file:",
"\tfile.write(data.content)",
""
],
"description": "StackOverflow Demo: download surveyss"
},
"StackOverflow: unzip survey": {
"prefix": "sounzip",
"body": [
"import zipfile",
"with zipfile.ZipFile('survey2017.zip') as zip:",
"\tzip.extractall('survey2017')",
""
],
"description": "StackOverflow Demo: unzip survey"
},
"StackOverflow: cleanup files": {
"prefix": "socleanup",
"body": [
"import shutil, os",
"shutil.move('survey2017/survey_results_public.csv', 'survey2017.csv')",
"shutil.rmtree('survey2017')",
"os.remove('survey2017.zip')",
""
],
"description": "StackOverflow Demo: cleanup files"
},
"StackOverflow: fix totals": {
"prefix": "sototal",
"body": [
"if year < 2016:",
"\tnotNull = languages.apply(lambda x: pd.notnull(x)).sum(axis=1)",
"\ttotal = notNull[notNull > 0].shape[0]"
],
"description": "StackOverflow Demo: fix totals for surveys pre 2016"
}
}