@@ -184,14 +184,14 @@ Extract first match in each subject (extract)
184
184
185
185
The ``extract `` method accepts a `regular expression
186
186
<https://docs.python.org/2/library/re.html> `__ with at least one
187
- capture group.
187
+ capture group.
188
188
189
189
Extracting a regular expression with more than one group returns a
190
190
DataFrame with one column per group.
191
191
192
192
.. ipython :: python
193
193
194
- pd.Series([' a1' , ' b2' , ' c3' ]).str.extract(' ([ab])(\d)' )
194
+ pd.Series([' a1' , ' b2' , ' c3' ]).str.extract(' ([ab])(\d)' , expand = False )
195
195
196
196
Elements that do not match return a row filled with ``NaN ``. Thus, a
197
197
Series of messy strings can be "converted" into a like-indexed Series
@@ -204,13 +204,13 @@ Named groups like
204
204
205
205
.. ipython :: python
206
206
207
- pd.Series([' a1' , ' b2' , ' c3' ]).str.extract(' (?P<letter>[ab])(?P<digit>\d)' )
207
+ pd.Series([' a1' , ' b2' , ' c3' ]).str.extract(' (?P<letter>[ab])(?P<digit>\d)' , expand = False )
208
208
209
209
and optional groups like
210
210
211
211
.. ipython :: python
212
212
213
- pd.Series([' a1' , ' b2' , ' 3' ]).str.extract(' ([ab])?(\d)' )
213
+ pd.Series([' a1' , ' b2' , ' 3' ]).str.extract(' ([ab])?(\d)' , expand = False )
214
214
215
215
can also be used. Note that any capture group names in the regular
216
216
expression will be used for column names; otherwise capture group
@@ -281,7 +281,7 @@ Unlike ``extract`` (which returns only the first match),
281
281
282
282
s = pd.Series([" a1a2" , " b1" , " c1" ], [" A" , " B" , " C" ])
283
283
s
284
- s.str.extract(" [ab](?P<digit>\d)" )
284
+ s.str.extract(" [ab](?P<digit>\d)" , expand = False )
285
285
286
286
.. versionadded :: 0.18.0
287
287
@@ -307,7 +307,7 @@ then ``extractall(pat).xs(0, level='match')`` gives the same result as
307
307
308
308
.. ipython :: python
309
309
310
- extract_result = s.str.extract(two_groups)
310
+ extract_result = s.str.extract(two_groups, expand = False )
311
311
extract_result
312
312
extractall_result = s.str.extractall(two_groups)
313
313
extractall_result
0 commit comments