Мой код:
import re
# Remove mentions (@username)
df['full_text'] = df['full_text'].astype(str).apply(lambda x: re.sub(r'@\w+', '', x))
# Remove hashtags (#hashtag)
df['full_text'] = df['full_text'].astype(str).apply(lambda x: re.sub(r'#\w+', '', x))
# Remove links (http:// or https://)
df['full_text'] = df['full_text'].astype(str).apply(lambda x: re.sub(r'https?://\S+', '', x))
df['full_text'] = df['full_text'].astype(str).apply(lambda x: re.sub(r'www\.\S+', '',x))
Выход:
TypeError Traceback (most recent call last)
in ()
2 import re
3 # Remove mentions (@username)
----> 4 df['full_text'] = df['full_text'].astype(str).apply(lambda x: re.sub(r'@\w+', '', x))
5 # Remove hashtags (#hashtag)
6 df['full_text'] = df['full_text'].astype(str).apply(lambda x: re.sub(r'#\w+', '', x))
5 frames
/usr/local/lib/python3.10/dist-packages/pandas/core/dtypes/common.py in pandas_dtype(dtype)
1689 # Hence enabling DeprecationWarning
1690 warnings.simplefilter("always", DeprecationWarning)
-> 1691 npdtype = np.dtype(dtype)
1692 except SyntaxError as err:
1693 # np.dtype uses `eval` which can raise SyntaxError
TypeError: Cannot interpret '' as a data type
Подробнее здесь: https://stackoverflow.com/questions/786 ... ta-type-wh
Сообщение об ошибке указывает, что «невозможно интерпретировать строку модуля как тип данных» при использовании «astype( ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Почему я получаю сообщение об ошибке. Объект «int» не имеет атрибута «astype»?
Anonymous » » в форуме Python - 0 Ответы
- 17 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Ошибка типа: невозможно интерпретировать «torch.uint8» как тип данных.
Anonymous » » в форуме Python - 0 Ответы
- 28 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как я могу решить сообщение «Нет модуля с именем" Frontend '"" Сообщение об ошибке?
Anonymous » » в форуме Python - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-