Skip to content

Commit 65cf65a

Browse files
committed
more snippits
1 parent d987886 commit 65cf65a

3 files changed

+365
-20
lines changed

code_py_template-Copy0.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+
}

pandas_outliers.ipynb

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"metadata": {
33
"name": "",
4-
"signature": "sha256:d01871b223db933a2260b5817ae9abbbf82e0a6bd98d4414215f47e56db5204f"
4+
"signature": "sha256:debb2e45e28149e7e079d0a3a969dcdf39a4fd8626249ed712fdcb09699867dc"
55
},
66
"nbformat": 3,
77
"nbformat_minor": 0,
@@ -386,6 +386,13 @@
386386
],
387387
"prompt_number": 15
388388
},
389+
{
390+
"cell_type": "markdown",
391+
"metadata": {},
392+
"source": [
393+
"### Are there any values inthe score_1 above or below 2?"
394+
]
395+
},
389396
{
390397
"cell_type": "code",
391398
"collapsed": false,
@@ -395,25 +402,6 @@
395402
],
396403
"language": "python",
397404
"metadata": {},
398-
"outputs": [
399-
{
400-
"metadata": {},
401-
"output_type": "pyout",
402-
"prompt_number": 20,
403-
"text": [
404-
"17 2.465491\n",
405-
"Name: score_1, dtype: float64"
406-
]
407-
}
408-
],
409-
"prompt_number": 20
410-
},
411-
{
412-
"cell_type": "code",
413-
"collapsed": false,
414-
"input": [],
415-
"language": "python",
416-
"metadata": {},
417405
"outputs": []
418406
}
419407
],

0 commit comments

Comments
 (0)