Skip to content

Commit 09f8e6e

Browse files
author
craigsdennis
committed
QA notes from first half of Dave thoughts
1 parent 042cedc commit 09f8e6e

10 files changed

+151
-121
lines changed

Diff for: data/creation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def user_dict(self):
9999

100100
user_row_dict['adrian'] = {
101101
'first_name': 'Adrian',
102-
'last_name': 'Yang',
103-
'email': 'adrian.yang@teamtreehouse.com',
102+
'last_name': 'Fang',
103+
'email': 'adrian.fang@teamtreehouse.com',
104104
'email_verified': fake.email_verified(),
105105
'signup_date': fake.signup_date(),
106106
'referral_count': fake.random_int(0, 7),

Diff for: data/users.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
aaron,Aaron,Davis,[email protected],True,2018-08-31,6,18.14
33
acook,Anthony,Cook,[email protected],True,2018-05-12,2,55.45
44
adam.saunders,Adam,Saunders,[email protected],False,2018-05-29,3,72.12
5-
adrian,Adrian,Yang,adrian.yang@teamtreehouse.com,True,2018-04-28,3,30.01
5+
adrian,Adrian,Fang,adrian.fang@teamtreehouse.com,True,2018-04-28,3,30.01
66
adrian.blair,Adrian,Blair,[email protected],True,2018-06-16,7,25.85
77
alan9443,Alan,Pope,[email protected],True,2018-04-17,0,56.09
88
alexander7808,Alexander,Moore,[email protected],False,2018-03-27,2,87.71

Diff for: s1n01-creating-a-series.ipynb

+14-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
"source": [
2929
"## Creating from a dictionary\n",
3030
"\n",
31-
"Let's use this sample data here. In our example, `test_balance_data` is just a standard Python dictionary the key is username, and the value is that user's current account balance. "
31+
"\n",
32+
"Let's use this sample data here we got from CashBox. They want to track the balances of their users. This is how much money each user currently has in their account. CashBox requires that users create a username.\n",
33+
"\n",
34+
"In our example, `test_balance_data` is just a standard Python dictionary the key is username, and the value is that user's current account balance. "
3235
]
3336
},
3437
{
@@ -164,7 +167,7 @@
164167
"cell_type": "markdown",
165168
"metadata": {},
166169
"source": [
167-
"Note, the order of the labels is guaranteed. "
170+
"Note, the order of the labels is guaranteed to match the same order of the supplied index. "
168171
]
169172
},
170173
{
@@ -195,7 +198,7 @@
195198
"cell_type": "markdown",
196199
"metadata": {},
197200
"source": [
198-
"One thing to remember is that a NumPy array is also iterable. In fact, you'll find NumPy and Pandas get along really well together."
201+
"One thing to remember is that a NumPy array is also iterable, so you can create a new `Series` from an `ndarray`. In fact, you'll find NumPy and Pandas get along very well together."
199202
]
200203
},
201204
{
@@ -229,7 +232,7 @@
229232
"source": [
230233
"## Creating from a scalar and an index\n",
231234
"\n",
232-
"If you pass in a scalar that value will be broadcasted to the keys specified in the index argument"
235+
"If you pass in a scalar, remember that is a single value, it will be broadcast to each of the keys specified in the `index` keyword argument."
233236
]
234237
},
235238
{
@@ -257,6 +260,13 @@
257260
"pd.Series(20.00, index=[\"guil\", \"jay\", \"james\", \"ben\", \"nick\"])"
258261
]
259262
},
263+
{
264+
"cell_type": "markdown",
265+
"metadata": {},
266+
"source": [
267+
"In other words, each key is assigned the same scalar value for the entire `Series`."
268+
]
269+
},
260270
{
261271
"cell_type": "markdown",
262272
"metadata": {},

Diff for: s1n02-accessing-a-series.ipynb

+68-9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"source": [
77
"# Accessing a Series\n",
88
"\n",
9-
"There are multiple ways to get to the data that is stored in your `Series`. Let's explore the **`balances`** `Series`. \n",
9+
"There are multiple ways to get to the data stored in your `Series`. Let's explore the **`balances`** `Series`. \n",
1010
"\n",
11-
"Remember, the `Series` is indexed by username. The label is the username, the value is that user's balance."
11+
"Remember, the `Series` is indexed by username. The label is the username, the value is that user's cash balance."
1212
]
1313
},
1414
{
@@ -95,9 +95,9 @@
9595
"cell_type": "markdown",
9696
"metadata": {},
9797
"source": [
98-
"The value is wrapped in a `NumPy.Scalar` so that it keeps it's data type and will play well with others.\n",
98+
"The value is wrapped in a [`NumPy.Scalar`](https://docs.scipy.org/doc/numpy-1.15.0/reference/arrays.scalars.html) so that it keeps it's data type and will play well with other data types and NumPy data structures.\n",
9999
"\n",
100-
"The same positional indexing works just as it does with a standard list."
100+
"The same positional indexing works just as it does with a standard list. The indices begin start with 0, and negative numbers can be used to access values from the end of the list."
101101
]
102102
},
103103
{
@@ -156,6 +156,65 @@
156156
"### `Series` behave like dictionaries"
157157
]
158158
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 14,
162+
"metadata": {},
163+
"outputs": [
164+
{
165+
"data": {
166+
"text/markdown": [
167+
"The label pasan has a value of 20.0"
168+
],
169+
"text/plain": [
170+
"<IPython.core.display.Markdown object>"
171+
]
172+
},
173+
"metadata": {},
174+
"output_type": "display_data"
175+
},
176+
{
177+
"data": {
178+
"text/markdown": [
179+
"The label treasure has a value of 20.18"
180+
],
181+
"text/plain": [
182+
"<IPython.core.display.Markdown object>"
183+
]
184+
},
185+
"metadata": {},
186+
"output_type": "display_data"
187+
},
188+
{
189+
"data": {
190+
"text/markdown": [
191+
"The label ashley has a value of 1.05"
192+
],
193+
"text/plain": [
194+
"<IPython.core.display.Markdown object>"
195+
]
196+
},
197+
"metadata": {},
198+
"output_type": "display_data"
199+
},
200+
{
201+
"data": {
202+
"text/markdown": [
203+
"The label craig has a value of 42.42"
204+
],
205+
"text/plain": [
206+
"<IPython.core.display.Markdown object>"
207+
]
208+
},
209+
"metadata": {},
210+
"output_type": "display_data"
211+
}
212+
],
213+
"source": [
214+
"for label, value in balances.items():\n",
215+
" render(\"The label {} has a value of {}\".format(label, value))"
216+
]
217+
},
159218
{
160219
"cell_type": "code",
161220
"execution_count": 6,
@@ -259,9 +318,9 @@
259318
"cell_type": "markdown",
260319
"metadata": {},
261320
"source": [
262-
"## Accessing More Explicitly\n",
321+
"## Accessing More Explicitly with `loc` and `iloc`\n",
263322
"\n",
264-
"We are using indexing which can *either* be a label *or* a positional index. This can get confusing. It's possible to be more explicit, [which yes wise Pythonista](https://www.python.org/dev/peps/pep-0020/), is always better than implicit.\n",
323+
"So far we have used a label and a positional index to access the value. This can get confusing as to what is being used, a label or a position. Because of this ambiguity, it is possible to be more explicit, [which yes wise Pythonista](https://www.python.org/dev/peps/pep-0020/), is always better than implicit.\n",
265324
"\n",
266325
"A `Series` exposes a property named `loc` which can be used to explicitly lookup by label based indices only."
267326
]
@@ -321,15 +380,15 @@
321380
"## Accessing by Slice\n",
322381
"Like a NumPy array, a `Series` also provides a way to use slices to get different portions of the data, returned as a `Series`. \n",
323382
"\n",
324-
"*NOTE*: Slicing with indices vs. labels behaves differently. The latter is inclusive."
383+
"*WARNING*: Slicing with indices vs. labels behaves differently. The latter is inclusive."
325384
]
326385
},
327386
{
328387
"cell_type": "markdown",
329388
"metadata": {},
330389
"source": [
331390
"### Slicing by Positional Index\n",
332-
"When using positional indices, the slice is exclusive..."
391+
"When using positional indices, the slice is exclusive. The last item **is not** included."
333392
]
334393
},
335394
{
@@ -362,7 +421,7 @@
362421
"metadata": {},
363422
"source": [
364423
"### Slicing by Label\n",
365-
"When using labels, the slice is inclusive..."
424+
"When using labels, the slice is inclusive. The last item **is** included."
366425
]
367426
},
368427
{

Diff for: s1n03-vectorization-and-broadcasting.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"source": [
77
"# Series Vectorization and Broadcasting\n",
88
"\n",
9-
"Just like NumPy, pandas offers powerful vectorized methods and leans on broadcasting.\n",
9+
"Just like NumPy, pandas offers powerful vectorized methods. It also leans on broadcasting.\n",
1010
"\n",
1111
"Let's explore!"
1212
]
@@ -75,7 +75,7 @@
7575
"cell_type": "markdown",
7676
"metadata": {},
7777
"source": [
78-
"...it's important to remember to lean on vectorization and skip the loops altogether."
78+
"...it's important to remember to lean on vectorization and skip the loops altogether. Vectorization is faster and as you can see, easier to read and write."
7979
]
8080
},
8181
{
@@ -119,7 +119,7 @@
119119
"metadata": {},
120120
"source": [
121121
"### Broadcasting a Scalar\n",
122-
"Also just like NumPy arrays, the mathematical operators have been overridden to use the vectorized versions of the same opration."
122+
"Also just like NumPy arrays, the mathematical operators have been overridden to use the vectorized versions of the same operation."
123123
]
124124
},
125125
{
@@ -227,7 +227,7 @@
227227
"cell_type": "markdown",
228228
"metadata": {},
229229
"source": [
230-
"#### Using the `fill_value`\n",
230+
"#### Using the `fill_value` parameter\n",
231231
"It is possible to fill missing values so that everything aligns. The concept is to use the `add` method directly along with the the keyword argument `fill_value`."
232232
]
233233
},

Diff for: s1n04-creating-a-dataframe.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"cell_type": "markdown",
3838
"metadata": {},
3939
"source": [
40-
"If your data is already in rows and columns you can just pass it along to the constructor. Labels and Column headings will be automatically generated as a range."
40+
"If your data is already in rows and columns, like a list of lists, you can just pass it along to the constructor. Labels and Column headings will be automatically generated as a range."
4141
]
4242
},
4343
{

Diff for: s1n05-accessing-a-dataframe.ipynb

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"metadata": {},
66
"source": [
77
"# Accessing a DataFrame\n",
8-
"There are many [different choices for indexing](https://pandas.pydata.org/pandas-docs/stable/indexing.html#different-choices-for-indexing) DataFrames available.\n",
8+
"There are many [different choices for indexing](https://pandas.pydata.org/pandas-docs/stable/indexing.html#different-choices-for-indexing) DataFrames.\n",
99
"\n",
1010
"Let's explore!"
1111
]
@@ -36,7 +36,7 @@
3636
"## Retrieve a specific Series\n",
3737
"\n",
3838
"### By Column Name\n",
39-
"Each column is actually a `Series`. The `DataFrame` provides access to each of these `Series` by a column name index.\n",
39+
"Each column in a `DataFrame` is actually a `Series`. The `DataFrame` provides access to each of these `Series` by a column name index.\n",
4040
"\n",
4141
"For instance, to get the **`balance`** `Series`, you could just use that for the index."
4242
]
@@ -286,7 +286,9 @@
286286
"source": [
287287
"## Retrieve a Specific DataFrame Through Slicing\n",
288288
"\n",
289-
"Using the `loc` and `iloc` properties you can slice an existing `DataFrame` into a new one."
289+
"Using the `loc` and `iloc` properties you can slice an existing `DataFrame` into a new one.\n",
290+
"\n",
291+
"In the example below we use `:` in the rows axis to select all rows, and we specify which columns we want back using a list in the columns axis, ala NumPy Fancy Indexing."
290292
]
291293
},
292294
{

0 commit comments

Comments
 (0)