Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

subsetting a column and giving it a value using numpy

# Convert genre to a binary feature
music_df["genre"] = np.where(music_df["genre"] == "Rock", 1, 0)
#This will give a value 1 for all rock genre and 0 for others 
Source by campus.datacamp.com #
 
PREVIOUS NEXT
Tagged: #subsetting #column #giving #numpy
ADD COMMENT
Topic
Name
2+3 =