Skip to content

Commit b934977

Browse files
committed
more snippits
1 parent 675201c commit b934977

7 files changed

+422
-585
lines changed

.ipynb_checkpoints/Untitled1-checkpoint.ipynb

Lines changed: 0 additions & 9 deletions
This file was deleted.

.ipynb_checkpoints/Untitled3-checkpoint.ipynb

Lines changed: 0 additions & 9 deletions
This file was deleted.

.ipynb_checkpoints/csv_to_python_code-checkpoint.ipynb

Lines changed: 309 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"metadata": {
3+
"name": "",
4+
"signature": "sha256:5e580f7a8413995f29709c00333c02575e8247f09ab902a29076baeb03b53eda"
5+
},
6+
"nbformat": 3,
7+
"nbformat_minor": 0,
8+
"worksheets": [
9+
{
10+
"cells": [
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"# Test of proportion_percentage()"
16+
]
17+
},
18+
{
19+
"cell_type": "markdown",
20+
"metadata": {},
21+
"source": [
22+
"## Set the test data"
23+
]
24+
},
25+
{
26+
"cell_type": "code",
27+
"collapsed": false,
28+
"input": [
29+
"percent = [10, 15, 25, 50]\n",
30+
"proportion = [.10, .15, .25, .50]\n",
31+
"not_percent = [25, 32, 2245, 235]\n",
32+
"not_proportion = [.245, .325, 1.25, 5.425]\n",
33+
"\n",
34+
"data = {'percent': percent,\n",
35+
" 'proportion': proportion,\n",
36+
" 'not_percent': percent,\n",
37+
" 'not_proportion': not_proportion}"
38+
],
39+
"language": "python",
40+
"metadata": {},
41+
"outputs": [],
42+
"prompt_number": 33
43+
},
44+
{
45+
"cell_type": "markdown",
46+
"metadata": {},
47+
"source": [
48+
"## Create the function"
49+
]
50+
},
51+
{
52+
"cell_type": "code",
53+
"collapsed": false,
54+
"input": [
55+
"def proportion_probability(values, key=None, pos=None):\n",
56+
" prob = 0\n",
57+
"\n",
58+
" if sum(values) == 1 or sum(values) == 100:\n",
59+
" prob += 0.50\n",
60+
" else:\n",
61+
" return 0\n",
62+
"\n",
63+
" return prob"
64+
],
65+
"language": "python",
66+
"metadata": {},
67+
"outputs": [],
68+
"prompt_number": 34
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"## See the results"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"collapsed": false,
80+
"input": [
81+
"# Should return 0.5\n",
82+
"print(proportion_probability(percent, 'percent'))\n",
83+
"\n",
84+
"# Should return 0.5\n",
85+
"print(proportion_probability(proportion, 'proportion'))\n",
86+
"\n",
87+
"# Should return 0\n",
88+
"print(proportion_probability(not_percent, 'not_percent'))\n",
89+
"\n",
90+
"# Should return 0\n",
91+
"print(proportion_probability(not_proportion, 'not_proportion'))"
92+
],
93+
"language": "python",
94+
"metadata": {},
95+
"outputs": [
96+
{
97+
"output_type": "stream",
98+
"stream": "stdout",
99+
"text": [
100+
"0.5\n",
101+
"0.5\n",
102+
"0\n",
103+
"0\n"
104+
]
105+
}
106+
],
107+
"prompt_number": 36
108+
}
109+
],
110+
"metadata": {}
111+
}
112+
]
113+
}

Untitled1.ipynb

Lines changed: 0 additions & 45 deletions
This file was deleted.

Untitled2.ipynb

Lines changed: 0 additions & 9 deletions
This file was deleted.

Untitled3.ipynb

Lines changed: 0 additions & 513 deletions
This file was deleted.

0 commit comments

Comments
 (0)