Skip to content

mapping with category data does not work #10324

Closed
@tnilanon

Description

@tnilanon
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeCompatpandas objects compatability with Numpy or Python functions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions