@@ -30,6 +30,43 @@ R packages.
30
30
Base R
31
31
------
32
32
33
+ Slicing with R's |c |_
34
+ ~~~~~~~~~~~~~~~~~~~~~
35
+
36
+ R makes it easy to access ``data.frame `` columns by name
37
+
38
+ .. code-block :: r
39
+
40
+ df <- data.frame(a=rnorm(5), b=rnorm(5), c=rnorm(5), d=rnorm(5), e=rnorm(5))
41
+ df[, c("a", "c", "e")]
42
+
43
+ or by integer location
44
+
45
+ .. code-block :: r
46
+
47
+ df <- data.frame(matrix(rnorm(1000), ncol=100))
48
+ df[, c(1:10, 25:30, 40, 50:100)]
49
+
50
+ Selecting multiple columns by name in ``pandas `` is straightforward
51
+
52
+ .. ipython :: python
53
+
54
+ df = DataFrame(np.random.randn(10 , 3 ), columns = list (' abc' ))
55
+ df[[' a' , ' c' ]]
56
+ df.loc[:, [' a' , ' c' ]]
57
+
58
+ Selecting multiple noncontiguous columns by integer location can be achieved
59
+ with a combination of the ``iloc `` indexer attribute and ``numpy.r_ ``.
60
+
61
+ .. ipython :: python
62
+
63
+ named = list (' abcdefg' )
64
+ n = 30
65
+ columns = named + np.arange(len (named), n).tolist()
66
+ df = DataFrame(np.random.randn(n, n), columns = columns)
67
+
68
+ df.iloc[:, np.r_[:10 , 24 :30 ]]
69
+
33
70
|aggregate |_
34
71
~~~~~~~~~~~~
35
72
@@ -407,6 +444,9 @@ The second approach is to use the :meth:`~pandas.DataFrame.groupby` method:
407
444
For more details and examples see :ref: `the reshaping documentation
408
445
<reshaping.pivot>` or :ref: `the groupby documentation<groupby.split> `.
409
446
447
+ .. |c | replace :: ``c ``
448
+ .. _c : http://stat.ethz.ch/R-manual/R-patched/library/base/html/c.html
449
+
410
450
.. |aggregate | replace :: ``aggregate ``
411
451
.. _aggregate : http://finzi.psych.upenn.edu/R/library/stats/html/aggregate.html
412
452
0 commit comments