-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpy_default_imports.js
45 lines (41 loc) · 1.45 KB
/
py_default_imports.js
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
define([
'base/js/namespace'
], function(
Jupyter
) {
function load_ipython_extension() {
var import_all = function () {
Jupyter.notebook.insert_cell_above('code', 0).set_text('' +
'import numpy as np\n' +
'import pandas as pd\n' +
'import matplotlib.pyplot as plt\n' +
'import matplotlib as mpl\n' +
'%pylab inline\n' +
'import seaborn as sns\n' +
'import re\n' +
'from collections import Counter, defaultdict\n' +
'from operator import itemgetter\n' +
'from joblib import Parallel, delayed\n' +
'from tqdm import tqdm, tqdm_notebook\n' +
'from IPython.display import display\n' +
'import os\n' +
'import datetime\n' +
'import itertools\n' +
'import pprint\n' +
'%autosave 600');
};
var action = {
icon: 'fa-rocket', // a font-awesome class used on buttons, etc
help : 'Import all the libs :D',
help_index : 'zz',
handler : import_all
};
var prefix = 'py_default_imports';
var action_name = 'import python libs';
var full_action_name = Jupyter.actions.register(action, action_name, prefix);
Jupyter.toolbar.add_buttons_group([full_action_name]);
}
return {
load_ipython_extension: load_ipython_extension
};
});