Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: mql5 python 
Python :: how to give tab space in python 
Python :: how i make viribal inside a string in python 
Python :: pyPS4Controller usage 
Python :: json object type in python 
Python :: list comperhension condition in python 
Python :: mlpclassifier check weights 
Python :: twitter python 
Python :: python advanced programs time 
Python :: Check if a Key is Already Present in a Dictionary 
Python :: Python Program to Display Powers of 2 Using Anonymous Function 
Python :: how to run another python file in python 
Python :: Lists and for loops in python 
Python :: when i press tab it shows ipynb_checkpoints/ in jupyter notebook 
Python :: animal quiz game in python 
Python :: isat in panadas datframe 
Python :: how to write statements in python 
Python :: get_scholarly_instance() 
Python :: matlab index last element 
Python :: multivariable traces f(x, y) = sin(x)cos(y) 
Python :: comment faire un long commentaire en python 
Python :: Desviacion estandard en pandas 
Python :: python pass statement 
Python :: python empty list boolean 
Python :: how can you make a data fram 
Python :: nvidia-smi with user name 
Python :: how to make an app that sends email in python 
Python :: child urls python 
Python :: axes in array 
Python :: raspian image with preinstalled python3 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =