Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [52]:
- import pandas as pd
- a = pd.Series(['a','b','c'],dtype="category")
- b = pd.Series(['a','b','c'],dtype="object")
- c = pd.Series(['a','b','cc'],dtype="object")
- In [54]:
- a==b
- ---------------------------------------------------------------------------
- TypeError Traceback (most recent call last)
- ...
- TypeError: Cannot compare a Categorical for op <built-in function eq> with type <class 'numpy.ndarray'>. If you want to compare values, use 'series <op> np.asarray(cat)'.
- In [59]:
- A = pd.DataFrame({'A':a,'B':[1,2,3]})
- B = pd.DataFrame({'A':b,'C':[4,5,6]})
- print(A.merge(B,on='A'))
- A B C
- 0 a 1 4
- 1 b 2 5
- 2 c 3 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement