Код: Выделить всё
>>> s = pd.Series(["some", "none", "all", "some"])
>>> s.dtypes
dtype('O')
>>> s.replace({"none": 0, "some": 1, "all": 2})
FutureWarning: Downcasting behavior in `replace` is deprecated and will be
removed in a future version. To retain the old behavior, explicitly call
`result.infer_objects(copy=False)`. To opt-in to the future behavior, set
`pd.set_option('future.no_silent_downcasting', True)`
0 1
1 0
2 2
3 1
dtype: int64
Подробнее здесь: https://stackoverflow.com/questions/792 ... sion-2-2-0
Мобильная версия