Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapping with category data does not work #10324

Closed
tnilanon opened this issue Jun 10, 2015 · 2 comments
Closed

mapping with category data does not work #10324

tnilanon opened this issue Jun 10, 2015 · 2 comments
Labels
Bug Categorical Categorical Data Type Compat pandas objects compatability with Numpy or Python functions
Milestone

Comments

@tnilanon
Copy link

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

@jreback
Copy link
Contributor

jreback commented Jun 10, 2015

This is a trivial change here

.values -> .get_values()

along with some tests of course

@jreback jreback added Bug Compat pandas objects compatability with Numpy or Python functions Categorical Categorical Data Type labels Jun 10, 2015
@jreback jreback added this to the 0.17.0 milestone Jun 10, 2015
@tnilanon
Copy link
Author

Thank you for such a quick response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

No branches or pull requests

2 participants