Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Creating column based on existing column

# using apply function to create a new column
df['Discounted_Price'] = df.apply(lambda row: row.Cost - 
                                  (row.Cost * 0.1), axis = 1)
  
# Print the DataFrame after addition
# of new column
print(df)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Creating #column #based #existing #column
ADD COMMENT
Topic
Name
5+5 =