Advertisement
Guest User

id kategorii filmu na Youtube - kolumny binarne z id kategor

a guest
Oct 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. id_kat=(2, 1, 10, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44)
  2.  
  3. def is_category(catId, colId):
  4.     if catId==colId:
  5.         return 1
  6.     else:
  7.         return 0
  8.    
  9. for i in range( len(id_kat) ):
  10.     df2['iscat_'+str(id_kat[i]) ] = df2.categoryId.apply(lambda x: is_category(x, id_kat[i]) )
  11.    
  12. # w wyniku tego do dataframe zostały doklejony kolumny iscat_1..iscat_44 z kodowaniem binarnym.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement