4
4
5
5
Comparison with SAS
6
6
********************
7
+
7
8
For potential users coming from `SAS <https://en.wikipedia.org/wiki/SAS_(software) >`__
8
9
this page is meant to demonstrate how different SAS operations would be
9
10
performed in pandas.
10
11
11
12
.. include :: includes/introduction.rst
12
13
13
- .. note ::
14
-
15
- Throughout this tutorial, the pandas ``DataFrame `` will be displayed by calling
16
- ``df.head() ``, which displays the first N (default 5) rows of the ``DataFrame ``.
17
- This is often used in interactive work (e.g. `Jupyter notebook
18
- <https://jupyter.org/> `_ or terminal) - the equivalent in SAS would be:
19
-
20
- .. code-block :: sas
21
-
22
- proc print data= df(obs = 5 );
23
- run;
24
14
25
15
Data structures
26
16
---------------
@@ -120,7 +110,7 @@ The pandas method is :func:`read_csv`, which works similarly.
120
110
" pandas/master/pandas/tests/io/data/csv/tips.csv"
121
111
)
122
112
tips = pd.read_csv(url)
123
- tips.head()
113
+ tips
124
114
125
115
126
116
Like ``PROC IMPORT ``, ``read_csv `` can take a number of parameters to specify
@@ -138,6 +128,19 @@ In addition to text/csv, pandas supports a variety of other data formats
138
128
such as Excel, HDF5, and SQL databases. These are all read via a ``pd.read_* ``
139
129
function. See the :ref: `IO documentation<io> ` for more details.
140
130
131
+ Limiting output
132
+ ~~~~~~~~~~~~~~~
133
+
134
+ .. include :: includes/limit.rst
135
+
136
+ The equivalent in SAS would be:
137
+
138
+ .. code-block :: sas
139
+
140
+ proc print data= df(obs = 5 );
141
+ run;
142
+
143
+
141
144
Exporting data
142
145
~~~~~~~~~~~~~~
143
146
@@ -181,7 +184,7 @@ New columns can be assigned in the same way.
181
184
182
185
tips[" total_bill" ] = tips[" total_bill" ] - 2
183
186
tips[" new_bill" ] = tips[" total_bill" ] / 2.0
184
- tips.head()
187
+ tips
185
188
186
189
.. ipython :: python
187
190
:suppress:
@@ -283,13 +286,13 @@ The same operations are expressed in pandas below.
283
286
.. ipython :: python
284
287
285
288
# keep
286
- tips[[" sex" , " total_bill" , " tip" ]].head()
289
+ tips[[" sex" , " total_bill" , " tip" ]]
287
290
288
291
# drop
289
- tips.drop(" sex" , axis = 1 ).head()
292
+ tips.drop(" sex" , axis = 1 )
290
293
291
294
# rename
292
- tips.rename(columns = {" total_bill" : " total_bill_2" }).head()
295
+ tips.rename(columns = {" total_bill" : " total_bill_2" })
293
296
294
297
295
298
Sorting by values
0 commit comments