mapping with category data does not work · Issue #10324 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
import pandas as pd
a = pd.Series([1, 2, 3, 4])
b = pd.Series(["even", "odd", "even", "odd"], dtype="category")
c = pd.Series(["even", "odd", "even", "odd"])
print("-- map by category")
try:
print(a.map(b))
except AttributeError as e:
print(e)
print("-- map by string")
print(a.map(c))
has the following output:
-- map by category
'Categorical' object has no attribute 'flags'
-- map by string
0 odd
1 even
2 odd
3 NaN
dtype: object