Skip to content

Commit 0d36331

Browse files
authored
Fixing exercise 1 solution
Assuming that the indexing is still by key "Name", then the use of `titanic.loc` wants the key to slice. Another solution is to reindex by passenger ID, but then the loc and iloc solutions would look identical...
1 parent b2eaaed commit 0d36331

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/pandas.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Exercises 1
176176
.. solution::
177177

178178
- Mean age of the first 10 passengers: ``titanic.iloc[:10,:]["Age"].mean()``
179-
or ``titanic.loc[:9,"Age"].mean()`` or ``df.iloc[:10,5].mean()``.
179+
or ``titanic.loc[:"Nasser, Mrs. Nicholas (Adele Achem)","Age"].mean()`` or ``titanic.iloc[:10,4].mean()``.
180180
- Survival rate among passengers over and under average age:
181181
``titanic[titanic["Age"] > titanic["Age"].mean()]["Survived"].mean()`` and
182182
``titanic[titanic["Age"] < titanic["Age"].mean()]["Survived"].mean()``.

0 commit comments

Comments
 (0)