File tree Expand file tree Collapse file tree 7 files changed +129
-194
lines changed
Filter options
Expand file tree Collapse file tree 7 files changed +129
-194
lines changed
Original file line number Diff line number Diff line change 1
1
# Python Snippets
2
2
3
- These __ Python Snippets__ are tested with Python 3.5 .x. All snippets are
3
+ These __ Python Snippets__ are tested with Python 3.6 .x. All snippets are
4
4
available as Jupyter notebooks (http://jupyter.org/ ).
5
5
6
6
7
7
## Get started...
8
8
To get started create a virtual environment and install the required packages.
9
9
10
- ### Virtualenv
11
- The following example shows how to create an environment with
12
- _ "virtualenv"_ (https://virtualenv.pypa.io/ )
13
- and Python 3.5 with the required packages.
10
+ - Juypter Notebook
11
+ - pandas
12
+ - geojson
13
+ - beautifulsoup4
14
+ - feedparser
15
+ - scikit-image
16
+ - matplotlib
14
17
15
- ``` bash
16
- virtualenv --python=/usr/bin/python3.5 py35-ps
17
-
18
- source py35-ps/bin/activate
19
-
20
- pip install -r requirements.txt
21
- ```
22
18
23
19
### Conda
24
20
The following example shows how to create an environment with _ "conda"_
25
- (http://conda.pydata.org/ ) and Python 3.5 with
21
+ (http://conda.pydata.org/ ) and Python 3.6 with
26
22
the required packages.
27
23
28
24
``` bash
29
- conda create -n py35 -ps python=3.5
25
+ conda create -n py36 -ps python=3.6
30
26
31
- source activate py35 -ps
27
+ source activate py36 -ps
32
28
33
- pip install -r requirements.txt
34
29
```
35
30
36
31
## The Python Snippets
@@ -47,4 +42,4 @@ __HTTP__
47
42
- [ Extract the text from a HTML document with Beautiful Soup] ( http/beautifulsoup4.ipynb )
48
43
49
44
__ Image__
50
- - tbd
45
+ - [ Image diff with scikit-image ] ( image/image_diff.ipynb )
Original file line number Diff line number Diff line change 42
42
},
43
43
{
44
44
"cell_type" : " code" ,
45
- "execution_count" : 1 ,
46
- "metadata" : {
47
- "collapsed" : false
48
- },
45
+ "execution_count" : 2 ,
46
+ "metadata" : {},
49
47
"outputs" : [
50
48
{
51
49
"data" : {
52
50
"text/html" : [
53
51
" <div>\n " ,
52
+ " <style scoped>\n " ,
53
+ " .dataframe tbody tr th:only-of-type {\n " ,
54
+ " vertical-align: middle;\n " ,
55
+ " }\n " ,
56
+ " \n " ,
57
+ " .dataframe tbody tr th {\n " ,
58
+ " vertical-align: top;\n " ,
59
+ " }\n " ,
60
+ " \n " ,
61
+ " .dataframe thead th {\n " ,
62
+ " text-align: right;\n " ,
63
+ " }\n " ,
64
+ " </style>\n " ,
54
65
" <table border=\" 1\" class=\" dataframe\" >\n " ,
55
66
" <thead>\n " ,
56
67
" <tr style=\" text-align: right;\" >\n " ,
116
127
" 4 22.0 7.589551 47.547405 277.0 Basel SBB"
117
128
]
118
129
},
119
- "execution_count" : 1 ,
130
+ "execution_count" : 2 ,
120
131
"metadata" : {},
121
132
"output_type" : " execute_result"
122
133
}
137
148
},
138
149
{
139
150
"cell_type" : " code" ,
140
- "execution_count" : 2 ,
151
+ "execution_count" : 3 ,
141
152
"metadata" : {
142
- "collapsed" : false ,
143
153
"scrolled" : true
144
154
},
145
155
"outputs" : [],
161
171
},
162
172
{
163
173
"cell_type" : " code" ,
164
- "execution_count" : 3 ,
165
- "metadata" : {
166
- "collapsed" : false
167
- },
174
+ "execution_count" : 4 ,
175
+ "metadata" : {},
168
176
"outputs" : [
169
177
{
170
178
"name" : " stdout" ,
195
203
},
196
204
{
197
205
"cell_type" : " code" ,
198
- "execution_count" : 4 ,
199
- "metadata" : {
200
- "collapsed" : false
201
- },
206
+ "execution_count" : 5 ,
207
+ "metadata" : {},
202
208
"outputs" : [
203
209
{
204
210
"data" : {
205
211
"text/plain" : [
206
212
" \"\\ nwith open('stations.geojson', 'w') as file:\\ n file.write(dump)\\ n\" "
207
213
]
208
214
},
209
- "execution_count" : 4 ,
215
+ "execution_count" : 5 ,
210
216
"metadata" : {},
211
217
"output_type" : " execute_result"
212
218
}
232
238
{
233
239
"cell_type" : " code" ,
234
240
"execution_count" : null ,
235
- "metadata" : {
236
- "collapsed" : true
237
- },
241
+ "metadata" : {},
238
242
"outputs" : [],
239
243
"source" : []
240
244
}
255
259
"name" : " python" ,
256
260
"nbconvert_exporter" : " python" ,
257
261
"pygments_lexer" : " ipython3" ,
258
- "version" : " 3.5.2 "
262
+ "version" : " 3.6.7 "
259
263
}
260
264
},
261
265
"nbformat" : 4 ,
Original file line number Diff line number Diff line change 11
11
},
12
12
{
13
13
"cell_type" : " code" ,
14
- "execution_count" : null ,
15
- "metadata" : {
16
- "collapsed" : true
17
- },
14
+ "execution_count" : 1 ,
15
+ "metadata" : {},
18
16
"outputs" : [],
19
17
"source" : [
20
18
" html_doc = \"\"\"\n " ,
41
39
},
42
40
{
43
41
"cell_type" : " code" ,
44
- "execution_count" : null ,
45
- "metadata" : {
46
- "collapsed" : false
47
- },
42
+ "execution_count" : 2 ,
43
+ "metadata" : {},
48
44
"outputs" : [],
49
45
"source" : [
50
46
" from bs4 import BeautifulSoup\n " ,
80
76
},
81
77
{
82
78
"cell_type" : " code" ,
83
- "execution_count" : 13 ,
84
- "metadata" : {
85
- "collapsed" : false
86
- },
79
+ "execution_count" : 3 ,
80
+ "metadata" : {},
87
81
"outputs" : [
88
82
{
89
83
"data" : {
90
84
"text/plain" : [
91
85
" 'My new page'"
92
86
]
93
87
},
94
- "execution_count" : 13 ,
88
+ "execution_count" : 3 ,
95
89
"metadata" : {},
96
90
"output_type" : " execute_result"
97
91
}
109
103
},
110
104
{
111
105
"cell_type" : " code" ,
112
- "execution_count" : 14 ,
113
- "metadata" : {
114
- "collapsed" : false
115
- },
106
+ "execution_count" : 4 ,
107
+ "metadata" : {},
116
108
"outputs" : [
117
109
{
118
110
"name" : " stdout" ,
138
130
},
139
131
{
140
132
"cell_type" : " code" ,
141
- "execution_count" : 15 ,
142
- "metadata" : {
143
- "collapsed" : false
144
- },
133
+ "execution_count" : 5 ,
134
+ "metadata" : {},
145
135
"outputs" : [
146
136
{
147
137
"data" : {
148
138
"text/plain" : [
149
139
" '\\ nMy new page\\ n\\ nCool my new page\\ nI have written the following articles:\\ nA1,\\ nA2\\ nA3;\\ n\\ n...\\ n'"
150
140
]
151
141
},
152
- "execution_count" : 15 ,
142
+ "execution_count" : 5 ,
153
143
"metadata" : {},
154
144
"output_type" : " execute_result"
155
145
}
175
165
"name" : " python" ,
176
166
"nbconvert_exporter" : " python" ,
177
167
"pygments_lexer" : " ipython3" ,
178
- "version" : " 3.5.2 "
168
+ "version" : " 3.6.7 "
179
169
}
180
170
},
181
171
"nbformat" : 4 ,
Original file line number Diff line number Diff line change 11
11
},
12
12
{
13
13
"cell_type" : " code" ,
14
- "execution_count" : 21 ,
15
- "metadata" : {
16
- "collapsed" : false
17
- },
14
+ "execution_count" : 1 ,
15
+ "metadata" : {},
18
16
"outputs" : [],
19
17
"source" : [
20
18
" import urllib.request"
30
28
},
31
29
{
32
30
"cell_type" : " code" ,
33
- "execution_count" : 22 ,
34
- "metadata" : {
35
- "collapsed" : false
36
- },
31
+ "execution_count" : 2 ,
32
+ "metadata" : {},
37
33
"outputs" : [],
38
34
"source" : [
39
35
" url = 'https://medium.com/tag/machine-learning'\n " ,
50
46
},
51
47
{
52
48
"cell_type" : " code" ,
53
- "execution_count" : 23 ,
54
- "metadata" : {
55
- "collapsed" : false
56
- },
49
+ "execution_count" : 3 ,
50
+ "metadata" : {},
57
51
"outputs" : [
58
52
{
59
53
"name" : " stdout" ,
76
70
},
77
71
{
78
72
"cell_type" : " code" ,
79
- "execution_count" : 24 ,
80
- "metadata" : {
81
- "collapsed" : false
82
- },
73
+ "execution_count" : 4 ,
74
+ "metadata" : {},
83
75
"outputs" : [
84
76
{
85
77
"data" : {
86
78
"text/plain" : [
87
79
" 'text/html; charset=utf-8'"
88
80
]
89
81
},
90
- "execution_count" : 24 ,
82
+ "execution_count" : 4 ,
91
83
"metadata" : {},
92
84
"output_type" : " execute_result"
93
85
}
105
97
},
106
98
{
107
99
"cell_type" : " code" ,
108
- "execution_count" : 25 ,
109
- "metadata" : {
110
- "collapsed" : false
111
- },
100
+ "execution_count" : 5 ,
101
+ "metadata" : {},
112
102
"outputs" : [
113
103
{
114
104
"data" : {
115
105
"text/plain" : [
116
- " b'<!DOCTYPE html><html xmlns:cc=\" http://creativecommons.org/ns#\" ><head prefix=\" og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# medium-com: http://ogp.me/ns/fb/medium-com#\" ><meta http-equiv=\" Content-Type\" content=\" text/html; charset=utf-8\" ><meta name=\" viewport\" content=\" width=device-width, initial-scale=1\" ><title>Machine Learning \\ xe2\\ x80\\ x93 Medium</title><link rel=\" canonical\" href=\" https://medium.com/tag/machine-learning\" ><link id=\" feedLink\" rel=\" alternate \" type= \" application/rss+xml \" title= \" RSS \" href= \" /fee '"
106
+ " b'<!DOCTYPE html><html xmlns:cc=\" http://creativecommons.org/ns#\" ><head prefix=\" og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# medium-com: http://ogp.me/ns/fb/medium-com#\" ><meta http-equiv=\" Content-Type\" content=\" text/html; charset=utf-8\" ><meta name=\" viewport\" content=\" width=device-width, initial-scale=1.0, viewport-fit=contain \" ><title>The most insightful stories about Machine Learning \\ xe2\\ x80\\ x93 Medium</title><link rel=\" canonical\" href=\" https://medium.com/tag/machine-learning\" ><link id=\" feedLink\" rel=\" al '"
117
107
]
118
108
},
119
- "execution_count" : 25 ,
109
+ "execution_count" : 5 ,
120
110
"metadata" : {},
121
111
"output_type" : " execute_result"
122
112
}
125
115
" text = con.read()\n " ,
126
116
" text[:500]"
127
117
]
118
+ },
119
+ {
120
+ "cell_type" : " code" ,
121
+ "execution_count" : null ,
122
+ "metadata" : {},
123
+ "outputs" : [],
124
+ "source" : []
128
125
}
129
126
],
130
127
"metadata" : {
143
140
"name" : " python" ,
144
141
"nbconvert_exporter" : " python" ,
145
142
"pygments_lexer" : " ipython3" ,
146
- "version" : " 3.5.2 "
143
+ "version" : " 3.6.7 "
147
144
}
148
145
},
149
146
"nbformat" : 4 ,
You can’t perform that action at this time.
0 commit comments