A pattern capturing one or more digits is applied with Series.str.extract to a column where some values do not match. What appears in those rows?
Correct answer
A. NaN in the extracted column, because a non-match yields a missing value
18 views
A. NaN in the extracted column, because a non-match yields a missing value
18 views
str.extract returns one column per capture group and fills rows whose value does not match the pattern with NaN, so the result is a float or object column rather than a clean integer one. Pass expand=False to get a Series when there is a single group, and use contains or match with na=False when booleans are wanted. Non-string values are themselves treated as missing rather than raising.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is A? Ask here and get an explanation.