Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. In [52]:
  2. import pandas as pd
  3.  
  4. a = pd.Series(['a','b','c'],dtype="category")
  5. b = pd.Series(['a','b','c'],dtype="object")
  6. c = pd.Series(['a','b','cc'],dtype="object")
  7.  
  8. In [54]:
  9.  
  10. a==b
  11.  
  12. ---------------------------------------------------------------------------
  13. TypeError Traceback (most recent call last)
  14. ...
  15. 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)'.
  16.  
  17. In [59]:
  18. A = pd.DataFrame({'A':a,'B':[1,2,3]})
  19. B = pd.DataFrame({'A':b,'C':[4,5,6]})
  20. print(A.merge(B,on='A'))
  21. A B C
  22. 0 a 1 4
  23. 1 b 2 5
  24. 2 c 3 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement