Skip to content

Commit 413f47d

Browse files
committed
more snippits
1 parent 65cf65a commit 413f47d

10 files changed

+3441
-1349
lines changed

Untitled1.ipynb

+192
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:a6887993c0e25e3bdeb3dd84d13a0834a66760600ff034ae4732d8e8fe27b563"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "code",
13+
"collapsed": false,
14+
"input": [
15+
"import pandas as pd\n",
16+
"\n",
17+
"data = {'column1': ['a', 'a', 'a', 'b', 'c'], \n",
18+
" 'column2': [1, 4, 2, 5, 3]}\n",
19+
"df = pd.DataFrame(data, columns = ['column1', 'column2'])\n",
20+
"df"
21+
],
22+
"language": "python",
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"html": [
27+
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
28+
"<table border=\"1\" class=\"dataframe\">\n",
29+
" <thead>\n",
30+
" <tr style=\"text-align: right;\">\n",
31+
" <th></th>\n",
32+
" <th>column1</th>\n",
33+
" <th>column2</th>\n",
34+
" </tr>\n",
35+
" </thead>\n",
36+
" <tbody>\n",
37+
" <tr>\n",
38+
" <th>0</th>\n",
39+
" <td> a</td>\n",
40+
" <td> 1</td>\n",
41+
" </tr>\n",
42+
" <tr>\n",
43+
" <th>1</th>\n",
44+
" <td> a</td>\n",
45+
" <td> 4</td>\n",
46+
" </tr>\n",
47+
" <tr>\n",
48+
" <th>2</th>\n",
49+
" <td> a</td>\n",
50+
" <td> 2</td>\n",
51+
" </tr>\n",
52+
" <tr>\n",
53+
" <th>3</th>\n",
54+
" <td> b</td>\n",
55+
" <td> 5</td>\n",
56+
" </tr>\n",
57+
" <tr>\n",
58+
" <th>4</th>\n",
59+
" <td> c</td>\n",
60+
" <td> 3</td>\n",
61+
" </tr>\n",
62+
" </tbody>\n",
63+
"</table>\n",
64+
"<p>5 rows \u00d7 2 columns</p>\n",
65+
"</div>"
66+
],
67+
"metadata": {},
68+
"output_type": "pyout",
69+
"prompt_number": 5,
70+
"text": [
71+
" column1 column2\n",
72+
"0 a 1\n",
73+
"1 a 4\n",
74+
"2 a 2\n",
75+
"3 b 5\n",
76+
"4 c 3\n",
77+
"\n",
78+
"[5 rows x 2 columns]"
79+
]
80+
}
81+
],
82+
"prompt_number": 5
83+
},
84+
{
85+
"cell_type": "code",
86+
"collapsed": false,
87+
"input": [
88+
"df.column1"
89+
],
90+
"language": "python",
91+
"metadata": {},
92+
"outputs": [
93+
{
94+
"metadata": {},
95+
"output_type": "pyout",
96+
"prompt_number": 8,
97+
"text": [
98+
"0 a\n",
99+
"1 a\n",
100+
"2 a\n",
101+
"3 b\n",
102+
"4 c\n",
103+
"Name: column1, dtype: object"
104+
]
105+
}
106+
],
107+
"prompt_number": 8
108+
},
109+
{
110+
"cell_type": "code",
111+
"collapsed": false,
112+
"input": [
113+
"df['column1']"
114+
],
115+
"language": "python",
116+
"metadata": {},
117+
"outputs": [
118+
{
119+
"metadata": {},
120+
"output_type": "pyout",
121+
"prompt_number": 9,
122+
"text": [
123+
"0 a\n",
124+
"1 a\n",
125+
"2 a\n",
126+
"3 b\n",
127+
"4 c\n",
128+
"Name: column1, dtype: object"
129+
]
130+
}
131+
],
132+
"prompt_number": 9
133+
},
134+
{
135+
"cell_type": "code",
136+
"collapsed": false,
137+
"input": [
138+
"df.column1.value_counts()"
139+
],
140+
"language": "python",
141+
"metadata": {},
142+
"outputs": [
143+
{
144+
"metadata": {},
145+
"output_type": "pyout",
146+
"prompt_number": 10,
147+
"text": [
148+
"a 3\n",
149+
"c 1\n",
150+
"b 1\n",
151+
"dtype: int64"
152+
]
153+
}
154+
],
155+
"prompt_number": 10
156+
},
157+
{
158+
"cell_type": "code",
159+
"collapsed": false,
160+
"input": [
161+
"df['column1'].value_counts()"
162+
],
163+
"language": "python",
164+
"metadata": {},
165+
"outputs": [
166+
{
167+
"metadata": {},
168+
"output_type": "pyout",
169+
"prompt_number": 11,
170+
"text": [
171+
"a 3\n",
172+
"c 1\n",
173+
"b 1\n",
174+
"dtype: int64"
175+
]
176+
}
177+
],
178+
"prompt_number": 11
179+
},
180+
{
181+
"cell_type": "code",
182+
"collapsed": false,
183+
"input": [],
184+
"language": "python",
185+
"metadata": {},
186+
"outputs": []
187+
}
188+
],
189+
"metadata": {}
190+
}
191+
]
192+
}

Untitled2.ipynb

+107
Large diffs are not rendered by default.

code_py_template-Copy1.ipynb

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:584adad2f76292ba484cbe44d4af7098eb86fd4996c310edde9b6c17ea58f7d4"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"# code_py template\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/)."
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {},
23+
"source": [
24+
"### import modules"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"collapsed": false,
30+
"input": [
31+
"import pandas as pd"
32+
],
33+
"language": "python",
34+
"metadata": {},
35+
"outputs": [],
36+
"prompt_number": 1
37+
},
38+
{
39+
"cell_type": "markdown",
40+
"metadata": {},
41+
"source": [
42+
"### Create dataframe"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"collapsed": false,
48+
"input": [
49+
"raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], \n",
50+
" 'last_name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze'], \n",
51+
" 'age': [42, 52, 36, 24, 73], \n",
52+
" 'preTestScore': [4, 24, 31, 2, 3],\n",
53+
" 'postTestScore': [25, 94, 57, 62, 70]}\n",
54+
"df = pd.DataFrame(raw_data, columns = ['first_name', 'last_name', 'age', 'preTestScore', 'postTestScore'])\n",
55+
"df"
56+
],
57+
"language": "python",
58+
"metadata": {},
59+
"outputs": [
60+
{
61+
"html": [
62+
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
63+
"<table border=\"1\" class=\"dataframe\">\n",
64+
" <thead>\n",
65+
" <tr style=\"text-align: right;\">\n",
66+
" <th></th>\n",
67+
" <th>first_name</th>\n",
68+
" <th>last_name</th>\n",
69+
" <th>age</th>\n",
70+
" <th>preTestScore</th>\n",
71+
" <th>postTestScore</th>\n",
72+
" </tr>\n",
73+
" </thead>\n",
74+
" <tbody>\n",
75+
" <tr>\n",
76+
" <th>0</th>\n",
77+
" <td> Jason</td>\n",
78+
" <td> Miller</td>\n",
79+
" <td> 42</td>\n",
80+
" <td> 4</td>\n",
81+
" <td> 25</td>\n",
82+
" </tr>\n",
83+
" <tr>\n",
84+
" <th>1</th>\n",
85+
" <td> Molly</td>\n",
86+
" <td> Jacobson</td>\n",
87+
" <td> 52</td>\n",
88+
" <td> 24</td>\n",
89+
" <td> 94</td>\n",
90+
" </tr>\n",
91+
" <tr>\n",
92+
" <th>2</th>\n",
93+
" <td> Tina</td>\n",
94+
" <td> Ali</td>\n",
95+
" <td> 36</td>\n",
96+
" <td> 31</td>\n",
97+
" <td> 57</td>\n",
98+
" </tr>\n",
99+
" <tr>\n",
100+
" <th>3</th>\n",
101+
" <td> Jake</td>\n",
102+
" <td> Milner</td>\n",
103+
" <td> 24</td>\n",
104+
" <td> 2</td>\n",
105+
" <td> 62</td>\n",
106+
" </tr>\n",
107+
" <tr>\n",
108+
" <th>4</th>\n",
109+
" <td> Amy</td>\n",
110+
" <td> Cooze</td>\n",
111+
" <td> 73</td>\n",
112+
" <td> 3</td>\n",
113+
" <td> 70</td>\n",
114+
" </tr>\n",
115+
" </tbody>\n",
116+
"</table>\n",
117+
"<p>5 rows \u00d7 5 columns</p>\n",
118+
"</div>"
119+
],
120+
"metadata": {},
121+
"output_type": "pyout",
122+
"prompt_number": 2,
123+
"text": [
124+
" first_name last_name age preTestScore postTestScore\n",
125+
"0 Jason Miller 42 4 25\n",
126+
"1 Molly Jacobson 52 24 94\n",
127+
"2 Tina Ali 36 31 57\n",
128+
"3 Jake Milner 24 2 62\n",
129+
"4 Amy Cooze 73 3 70\n",
130+
"\n",
131+
"[5 rows x 5 columns]"
132+
]
133+
}
134+
],
135+
"prompt_number": 2
136+
},
137+
{
138+
"cell_type": "code",
139+
"collapsed": false,
140+
"input": [],
141+
"language": "python",
142+
"metadata": {},
143+
"outputs": []
144+
}
145+
],
146+
"metadata": {}
147+
}
148+
]
149+
}

0 commit comments

Comments
 (0)