@@ -184,14 +184,14 @@ Extract first match in each subject (extract)
184184
185185The ``extract `` method accepts a `regular expression
186186<https://docs.python.org/2/library/re.html> `__ with at least one
187- capture group.
187+ capture group.
188188
189189Extracting a regular expression with more than one group returns a
190190DataFrame with one column per group.
191191
192192.. ipython :: python
193193
194- pd.Series([' a1' , ' b2' , ' c3' ]).str.extract(' ([ab])(\d)' )
194+ pd.Series([' a1' , ' b2' , ' c3' ]).str.extract(' ([ab])(\d)' , expand = False )
195195
196196 Elements that do not match return a row filled with ``NaN ``. Thus, a
197197Series of messy strings can be "converted" into a like-indexed Series
@@ -204,13 +204,13 @@ Named groups like
204204
205205.. ipython :: python
206206
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 )
208208
209209 and optional groups like
210210
211211.. ipython :: python
212212
213- pd.Series([' a1' , ' b2' , ' 3' ]).str.extract(' ([ab])?(\d)' )
213+ pd.Series([' a1' , ' b2' , ' 3' ]).str.extract(' ([ab])?(\d)' , expand = False )
214214
215215 can also be used. Note that any capture group names in the regular
216216expression will be used for column names; otherwise capture group
@@ -281,7 +281,7 @@ Unlike ``extract`` (which returns only the first match),
281281
282282 s = pd.Series([" a1a2" , " b1" , " c1" ], [" A" , " B" , " C" ])
283283 s
284- s.str.extract(" [ab](?P<digit>\d)" )
284+ s.str.extract(" [ab](?P<digit>\d)" , expand = False )
285285
286286 .. versionadded :: 0.18.0
287287
@@ -307,7 +307,7 @@ then ``extractall(pat).xs(0, level='match')`` gives the same result as
307307
308308.. ipython :: python
309309
310- extract_result = s.str.extract(two_groups)
310+ extract_result = s.str.extract(two_groups, expand = False )
311311 extract_result
312312 extractall_result = s.str.extractall(two_groups)
313313 extractall_result
0 commit comments