Jun-15-2018, 11:42 AM
I have a column 'original_title', where I have different film titles i.a. all films of Star Wars (+ the name of the episode) and Star Trek (+ the name of the episode). I want to create one column which will show me only 'star trek' (without the name of episode), 'star wars' and 'na'.
This is my code for the new column:
This is my code for the new column:
df['Trek_Wars'] = pd.np.where(df.original_title.str.contains("Star Wars"), "star_wars", pd.np.where(df.original_title.str.contains("Star Trek"), "star_trek"))However, it doesn't work
ValueError Traceback (most recent call last) in () 1 df['Trek_Wars'] = pd.np.where(df.original_title.str.contains("Star Wars"), "star_wars", ----> 2 pd.np.where(df.original_title.str.contains("Star Trek"), "star_trek")) ValueError: either both or neither of x and y should be givenWhat should I do?