Это дополнительный вопрос к Regex внутри findall vs regex inside count
.str.count('\w')
работает для меня при вызове в столбце кадра данных, но не при вызове вСерии.
X_train[0:7]
- это серия:
872 I'll text you when I drop x off
831 Hi mate its RV did u hav a nice hol just a mes...
1273 network operator. The service is free. For T &...
3314 FREE MESSAGE Activate your 500 FREE Text Messa...
4929 Hi, the SEXYCHAT girls are waiting for you to ...
4249 How much for an eighth?
3640 You can stop further club tones by replying \S...
Name: text, dtype: object
X_train[0:7].str.count('\w')
возвращает
872 0
831 0
1273 0
3314 0
4929 0
4249 0
3640 1
Name: text, dtype: int64)
При вызове натой же серии, преобразованной в столбец данных:
d = X_train[0:7]
df = pd.DataFrame(data=d)
df['col1'].str.count('\w')
возвращает:
872 23
831 101
1273 50
3314 120
4929 98
4249 18
3640 98
Name: col1, dtype: int64
Почему он работает с столбцом данных, а не с серией?Благодарен за ваш совет.