You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Closes: #135 (convert column back to years)
- Various other minor clarity changes, for example:
- typo fixing
- more explanation
- add some `df` to show how we see values as we work.
- etc.
- All code verified to work.
- Review: probably can be automerge
Copy file name to clipboardExpand all lines: content/pandas.rst
+49-30Lines changed: 49 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,8 +30,10 @@ material, including:
30
30
- a `cheatsheet <https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf>`__
31
31
- a `cookbook <https://pandas.pydata.org/docs/user_guide/cookbook.html#cookbook>`__.
32
32
33
-
Let's get a flavor of what we can do with pandas. We will be working with an
34
-
example dataset containing the passenger list from the Titanic, which is often used in Kaggle competitions and data science tutorials. First step is to load pandas::
33
+
A quick Pandas preview
34
+
----------------------
35
+
36
+
Let's get a flavor of what we can do with pandas (you won't be able to follow everything yet). We will be working with an example dataset containing the passenger list from the Titanic, which is often used in Kaggle competitions and data science tutorials. First step is to load pandas::
35
37
36
38
import pandas as pd
37
39
@@ -48,6 +50,8 @@ print some summary statistics of its numerical data::
48
50
# print the first 5 lines of the dataframe
49
51
titanic.head()
50
52
53
+
::
54
+
51
55
# print summary statistics for each column
52
56
titanic.describe()
53
57
@@ -85,6 +89,8 @@ Clearly, pandas dataframes allows us to do advanced analysis with very few comma
85
89
- Write a function name followed by question mark and execute the cell, e.g.
86
90
write ``titanic.hist?`` and hit ``SHIFT + ENTER``.
87
91
- Write the function name and hit ``SHIFT + TAB``.
92
+
- Right click and select "Show contextual help". This tab will
93
+
update with help for anything you click.
88
94
89
95
90
96
What's in a dataframe?
@@ -112,7 +118,10 @@ and reading the titanic.csv datafile into a dataframe if needed, see above)::
112
118
113
119
titanic["Age"]
114
120
titanic.Age # same as above
115
-
type(titanic["Age"])
121
+
122
+
::
123
+
124
+
type(titanic["Age"]) # a pandas Series object
116
125
117
126
The columns have names. Here's how to get them (:attr:`~pandas.DataFrame.columns`)::
118
127
@@ -123,10 +132,11 @@ However, the rows also have names! This is what Pandas calls the :obj:`~pandas.D
123
132
titanic.index
124
133
125
134
We saw above how to select a single column, but there are many ways of
126
-
selecting (and setting) single or multiple rows, columns and values. We can
127
-
refer to columns and rows either by number or by their name
0 commit comments