Skip to content

Commit 02cc13a

Browse files
committed
DOC: split out more includes from comparison docs
1 parent c85af37 commit 02cc13a

File tree

4 files changed

+28
-50
lines changed

4 files changed

+28
-50
lines changed

doc/source/getting_started/comparison/comparison_with_sas.rst

+2-25
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,8 @@ be used on new or existing columns.
173173
new_bill = total_bill / 2;
174174
run;
175175
176-
pandas provides similar vectorized operations by
177-
specifying the individual ``Series`` in the ``DataFrame``.
178-
New columns can be assigned in the same way.
176+
.. include:: includes/column_operations.rst
179177

180-
.. ipython:: python
181-
182-
tips["total_bill"] = tips["total_bill"] - 2
183-
tips["new_bill"] = tips["total_bill"] / 2.0
184-
tips.head()
185-
186-
.. ipython:: python
187-
:suppress:
188-
189-
tips = tips.drop("new_bill", axis=1)
190178

191179
Filtering
192180
~~~~~~~~~
@@ -278,18 +266,7 @@ drop, and rename columns.
278266
rename total_bill=total_bill_2;
279267
run;
280268
281-
The same operations are expressed in pandas below.
282-
283-
.. ipython:: python
284-
285-
# keep
286-
tips[["sex", "total_bill", "tip"]].head()
287-
288-
# drop
289-
tips.drop("sex", axis=1).head()
290-
291-
# rename
292-
tips.rename(columns={"total_bill": "total_bill_2"}).head()
269+
.. include:: includes/column_selection.rst
293270

294271

295272
Sorting by values

doc/source/getting_started/comparison/comparison_with_stata.rst

+2-25
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,8 @@ the column from the data set.
179179
generate new_bill = total_bill / 2
180180
drop new_bill
181181
182-
pandas provides similar vectorized operations by
183-
specifying the individual ``Series`` in the ``DataFrame``.
184-
New columns can be assigned in the same way. The :meth:`DataFrame.drop` method
185-
drops a column from the ``DataFrame``.
182+
.. include:: includes/column_operations.rst
186183

187-
.. ipython:: python
188-
189-
tips["total_bill"] = tips["total_bill"] - 2
190-
tips["new_bill"] = tips["total_bill"] / 2
191-
tips.head()
192-
193-
tips = tips.drop("new_bill", axis=1)
194184

195185
Filtering
196186
~~~~~~~~~
@@ -256,20 +246,7 @@ Stata provides keywords to select, drop, and rename columns.
256246
257247
rename total_bill total_bill_2
258248
259-
The same operations are expressed in pandas below. Note that in contrast to Stata, these
260-
operations do not happen in place. To make these changes persist, assign the operation back
261-
to a variable.
262-
263-
.. ipython:: python
264-
265-
# keep
266-
tips[["sex", "total_bill", "tip"]].head()
267-
268-
# drop
269-
tips.drop("sex", axis=1).head()
270-
271-
# rename
272-
tips.rename(columns={"total_bill": "total_bill_2"}).head()
249+
.. include:: includes/column_selection.rst
273250

274251

275252
Sorting by values
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pandas provides similar vectorized operations by specifying the individual ``Series`` in the
2+
``DataFrame``. New columns can be assigned in the same way. The :meth:`DataFrame.drop` method drops
3+
a column from the ``DataFrame``.
4+
5+
.. ipython:: python
6+
7+
tips["total_bill"] = tips["total_bill"] - 2
8+
tips["new_bill"] = tips["total_bill"] / 2
9+
tips.head()
10+
11+
tips = tips.drop("new_bill", axis=1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The same operations are expressed in pandas below. Note that these operations do not happen in
2+
place. To make these changes persist, assign the operation back to a variable.
3+
4+
.. ipython:: python
5+
6+
# keep
7+
tips[["sex", "total_bill", "tip"]].head()
8+
9+
# drop
10+
tips.drop("sex", axis=1).head()
11+
12+
# rename
13+
tips.rename(columns={"total_bill": "total_bill_2"}).head()

0 commit comments

Comments
 (0)