@@ -66,6 +66,44 @@ function.
66
66
For more details and examples see :ref: `the groupby documentation
67
67
<groupby.split>`.
68
68
69
+ |match |_
70
+ ~~~~~~~~~~~~
71
+
72
+ A common way to select data in R is using ``%in% `` which is defined using the
73
+ function ``match ``. The operator ``%in% `` is used to return a logical vector
74
+ indicating if there is a match or not:
75
+
76
+ .. code-block :: r
77
+
78
+ s <- 0:4
79
+ s %in% c(2,4)
80
+
81
+ The :meth: `~pandas.DataFrame.isin ` method is similar to R ``%in% `` operator:
82
+
83
+ .. ipython :: python
84
+
85
+ s = pd.Series(np.arange(5 ),dtype = np.float32)
86
+ s.isin([2 , 4 ])
87
+
88
+ The ``match `` function returns a vector of the positions of matches
89
+ of its first argument in its second:
90
+
91
+ .. code-block :: r
92
+
93
+ s <- 0:4
94
+ match(s, c(2,4))
95
+
96
+ The :meth: `~pandas.core.groupby.GroupBy.apply ` method can be used to replicate
97
+ this:
98
+
99
+ .. ipython :: python
100
+
101
+ s = pd.Series(np.arange(5 ),dtype = np.float32)
102
+ Series(pd.match(s,[2 ,4 ],np.nan))
103
+
104
+ For more details and examples see :ref: `the reshaping documentation
105
+ <indexing.basics.indexing_isin>`.
106
+
69
107
|tapply |_
70
108
~~~~~~~~~
71
109
@@ -372,6 +410,9 @@ For more details and examples see :ref:`the reshaping documentation
372
410
.. |aggregate | replace :: ``aggregate ``
373
411
.. _aggregate : http://finzi.psych.upenn.edu/R/library/stats/html/aggregate.html
374
412
413
+ .. |match | replace :: ``match `` / ``%in% ``
414
+ .. _match : http://finzi.psych.upenn.edu/R/library/base/html/match.html
415
+
375
416
.. |tapply | replace :: ``tapply ``
376
417
.. _tapply : http://finzi.psych.upenn.edu/R/library/base/html/tapply.html
377
418
0 commit comments