У меня есть столбец панд:
df ['Reviewer']
0 more, 25-34 Male on Treatment for 10 years or more
1 Idapida, 25-34 Female on Treatment for 2 to less than 5 years
2 Anna, 13-18 Female on Treatment for 5 to less than 10 years
3 Kepons, 55-64 on Treatment for 1 to 6 months
4 sammymaguire, 45-54 Female on Treatment for 1 to less than 2 years
Я хочу использовать следующие шаблоны регулярных выражений
ageRegex = re.compile('13-18|19-24|25-34|35-44|45-54|55-64|65-74|75 or
over')
timeRegex = re.compile('less than 1 month|1 to 6 months|6 months to less
than 1 year|1 to less than 2 years|2 to less than 5 years|5 to less than
10 years|10 years or more')
genderRegex = re.compile('Male|Female')
для извлечениявозраст, время и пол новых столбцов, которые будут выглядеть примерно так
0 25-34 10 years or more Male
1 25-34 Treatment for 2 to less than 5 years Female
2 13-18 Treatment for 5 to less than 10 years Female
3 55-64 Treatment for 1 to 6 months na
4 45-54 Treatment for 1 to less than 2 years Female
Я пробовал что-то вроде этого
df['age'] = ageRegex.findall(df['Reviewer'])
но я получаю ошибку
expected string or bytes-like object