Skip to content

Commit f96b0b2

Browse files
committed
Two more snippets.
1 parent b74f5b0 commit f96b0b2

10 files changed

+686
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:24d12ab64e5e93c82e0acf22e043d94d7006b033acc4160a5a99e702b6873929"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": []
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:24d12ab64e5e93c82e0acf22e043d94d7006b033acc4160a5a99e702b6873929"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": []
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:24d12ab64e5e93c82e0acf22e043d94d7006b033acc4160a5a99e702b6873929"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": []
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:c4d4b80c50d9a4163199a430712123ffb717d9ac217db16e9e2796ca883d4a3b"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"# View an image in iPython\n",
16+
"\n",
17+
"This snippit was written by [Chris R. Albon](http://www.chrisralbon.com/) and is part of his collection of [well-documented Python snippits](https://github.com/chrisalbon/code_py). All code is written in Python 3 in iPython notebook and offered under the [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/\"><img alt=\"Creative Commons License)."
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {},
23+
"source": [
24+
"## Display an image"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"collapsed": false,
30+
"input": [
31+
"# Load the ipython display and image module\n",
32+
"from IPython.display import Image\n",
33+
"from IPython.display import display"
34+
],
35+
"language": "python",
36+
"metadata": {},
37+
"outputs": [],
38+
"prompt_number": 4
39+
},
40+
{
41+
"cell_type": "code",
42+
"collapsed": false,
43+
"input": [
44+
"# display this image\n",
45+
"display(Image(url='http://history.nasa.gov/ap11ann/kippsphotos/5903.jpg'))"
46+
],
47+
"language": "python",
48+
"metadata": {},
49+
"outputs": [
50+
{
51+
"html": [
52+
"<img src=\"http://history.nasa.gov/ap11ann/kippsphotos/5903.jpg\"/>"
53+
],
54+
"metadata": {},
55+
"output_type": "display_data",
56+
"text": [
57+
"<IPython.core.display.Image at 0x105075d10>"
58+
]
59+
}
60+
],
61+
"prompt_number": 6
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"metadata": {},
66+
"source": [
67+
"## Display an svg"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"collapsed": false,
73+
"input": [
74+
"# Load the svg module\n",
75+
"from IPython.display import SVG\n",
76+
"\n",
77+
"# Display an svg\n",
78+
"SVG(url='http://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg')"
79+
],
80+
"language": "python",
81+
"metadata": {},
82+
"outputs": [
83+
{
84+
"metadata": {},
85+
"output_type": "pyout",
86+
"prompt_number": 8,
87+
"svg": [
88+
"<svg height=\"650\" width=\"1235\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
89+
"<defs>\n",
90+
"<polygon fill=\"#FFF\" id=\"pt\" points=\"-0.1624598481164531,0 0,-0.5 0.1624598481164531,0\" transform=\"scale(0.0616)\"/>\n",
91+
"<g id=\"star\"><use transform=\"rotate(-144)\" xlink:href=\"#pt\"/><use transform=\"rotate(-72)\" xlink:href=\"#pt\"/><use xlink:href=\"#pt\"/><use transform=\"rotate(72)\" xlink:href=\"#pt\"/><use transform=\"rotate(144)\" xlink:href=\"#pt\"/></g>\n",
92+
"<g id=\"s5\"><use x=\"-0.252\" xlink:href=\"#star\"/><use x=\"-0.126\" xlink:href=\"#star\"/><use xlink:href=\"#star\"/><use x=\"0.126\" xlink:href=\"#star\"/><use x=\"0.252\" xlink:href=\"#star\"/></g>\n",
93+
"<g id=\"s6\"><use x=\"-0.063\" xlink:href=\"#s5\"/><use x=\"0.315\" xlink:href=\"#star\"/></g>\n",
94+
"<g id=\"x4\"><use xlink:href=\"#s6\"/><use xlink:href=\"#s5\" y=\"0.054\"/><use xlink:href=\"#s6\" y=\"0.108\"/><use xlink:href=\"#s5\" y=\"0.162\"/></g>\n",
95+
"<g id=\"u\"><use xlink:href=\"#x4\" y=\"-0.216\"/><use xlink:href=\"#x4\"/><use xlink:href=\"#s6\" y=\"0.216\"/></g>\n",
96+
"<rect fill=\"#B22234\" height=\"50\" id=\"stripe\" width=\"1235\"/>\n",
97+
"</defs>\n",
98+
"<rect fill=\"#FFF\" height=\"650\" width=\"1235\"/><use xlink:href=\"#stripe\"/><use xlink:href=\"#stripe\" y=\"100\"/><use xlink:href=\"#stripe\" y=\"200\"/><use xlink:href=\"#stripe\" y=\"300\"/><use xlink:href=\"#stripe\" y=\"400\"/><use xlink:href=\"#stripe\" y=\"500\"/><use xlink:href=\"#stripe\" y=\"600\"/><rect fill=\"#3C3B6E\" height=\"350\" width=\"494\"/><use transform=\"translate(247,175) scale(650)\" xlink:href=\"#u\"/></svg>"
99+
],
100+
"text": [
101+
"<IPython.core.display.SVG at 0x1050a95d0>"
102+
]
103+
}
104+
],
105+
"prompt_number": 8
106+
},
107+
{
108+
"cell_type": "code",
109+
"collapsed": false,
110+
"input": [],
111+
"language": "python",
112+
"metadata": {},
113+
"outputs": []
114+
}
115+
],
116+
"metadata": {}
117+
}
118+
]
119+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:db50078750b3fd9416fa54cd78ec1d831c1d7d84df0778941f282ff4d5b9d503"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"# View an video in iPython\n",
16+
"\n",
17+
"This snippit was written by [Chris R. Albon](http://www.chrisralbon.com/) and is part of his collection of [well-documented Python snippits](https://github.com/chrisalbon/code_py). All code is written in Python 3 in iPython notebook and offered under the [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/\"><img alt=\"Creative Commons License)."
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {},
23+
"source": [
24+
"## Display an image"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"collapsed": false,
30+
"input": [
31+
"# load the youtube module\n",
32+
"from IPython.display import YouTubeVideo"
33+
],
34+
"language": "python",
35+
"metadata": {},
36+
"outputs": [],
37+
"prompt_number": 3
38+
},
39+
{
40+
"cell_type": "code",
41+
"collapsed": false,
42+
"input": [
43+
"# Display this particular youtube video\n",
44+
"YouTubeVideo('8inUHTdK6Rg')"
45+
],
46+
"language": "python",
47+
"metadata": {},
48+
"outputs": [
49+
{
50+
"html": [
51+
"\n",
52+
" <iframe\n",
53+
" width=\"400\"\n",
54+
" height=300\"\n",
55+
" src=\"https://www.youtube.com/embed/8inUHTdK6Rg\"\n",
56+
" frameborder=\"0\"\n",
57+
" allowfullscreen\n",
58+
" ></iframe>\n",
59+
" "
60+
],
61+
"metadata": {},
62+
"output_type": "pyout",
63+
"prompt_number": 4,
64+
"text": [
65+
"<IPython.lib.display.YouTubeVideo at 0x1049d80d0>"
66+
]
67+
}
68+
],
69+
"prompt_number": 4
70+
}
71+
],
72+
"metadata": {}
73+
}
74+
]
75+
}

Untitled0.ipynb

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:2cc9108e6871c598de2f6df79a7752ffa3e72f0e8f2c93c5a19126133dfdea06"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "code",
13+
"collapsed": false,
14+
"input": [],
15+
"language": "python",
16+
"metadata": {},
17+
"outputs": [],
18+
"prompt_number": 3
19+
},
20+
{
21+
"cell_type": "code",
22+
"collapsed": false,
23+
"input": [],
24+
"language": "python",
25+
"metadata": {},
26+
"outputs": [
27+
{
28+
"html": [
29+
"<img src=\"http://history.nasa.gov/ap11ann/kippsphotos/5903.jpg\"/>"
30+
],
31+
"metadata": {},
32+
"output_type": "display_data",
33+
"text": [
34+
"<IPython.core.display.Image at 0x106d41b50>"
35+
]
36+
}
37+
],
38+
"prompt_number": 6
39+
},
40+
{
41+
"cell_type": "code",
42+
"collapsed": false,
43+
"input": [],
44+
"language": "python",
45+
"metadata": {},
46+
"outputs": []
47+
}
48+
],
49+
"metadata": {}
50+
}
51+
]
52+
}

Untitled1.ipynb

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:f6eb8be8f8b0db5bee77d0bdb1d6a60fbf57380e817c36f8c9b4cef21611b702"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "code",
13+
"collapsed": false,
14+
"input": [],
15+
"language": "python",
16+
"metadata": {},
17+
"outputs": [
18+
{
19+
"html": [
20+
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
21+
"<table border=\"1\" class=\"dataframe\">\n",
22+
" <thead>\n",
23+
" <tr style=\"text-align: right;\">\n",
24+
" <th></th>\n",
25+
" <th>name</th>\n",
26+
" <th>reports_1</th>\n",
27+
" <th>reports_2</th>\n",
28+
" </tr>\n",
29+
" </thead>\n",
30+
" <tbody>\n",
31+
" <tr>\n",
32+
" <th>0</th>\n",
33+
" <td> Jason</td>\n",
34+
" <td> 3</td>\n",
35+
" <td> 4</td>\n",
36+
" </tr>\n",
37+
" <tr>\n",
38+
" <th>1</th>\n",
39+
" <td> Molly</td>\n",
40+
" <td> 42</td>\n",
41+
" <td> 24</td>\n",
42+
" </tr>\n",
43+
" <tr>\n",
44+
" <th>2</th>\n",
45+
" <td> Tina</td>\n",
46+
" <td> 25</td>\n",
47+
" <td> 31</td>\n",
48+
" </tr>\n",
49+
" <tr>\n",
50+
" <th>3</th>\n",
51+
" <td> Jake</td>\n",
52+
" <td> 25</td>\n",
53+
" <td> 2</td>\n",
54+
" </tr>\n",
55+
" <tr>\n",
56+
" <th>4</th>\n",
57+
" <td> Amy</td>\n",
58+
" <td> 25</td>\n",
59+
" <td> 3</td>\n",
60+
" </tr>\n",
61+
" </tbody>\n",
62+
"</table>\n",
63+
"</div>"
64+
],
65+
"metadata": {},
66+
"output_type": "pyout",
67+
"prompt_number": 4,
68+
"text": [
69+
" name reports_1 reports_2\n",
70+
"0 Jason 3 4\n",
71+
"1 Molly 42 24\n",
72+
"2 Tina 25 31\n",
73+
"3 Jake 25 2\n",
74+
"4 Amy 25 3"
75+
]
76+
}
77+
],
78+
"prompt_number": 4
79+
},
80+
{
81+
"cell_type": "code",
82+
"collapsed": false,
83+
"input": [],
84+
"language": "python",
85+
"metadata": {},
86+
"outputs": []
87+
}
88+
],
89+
"metadata": {}
90+
}
91+
]
92+
}

0 commit comments

Comments
 (0)