Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Create a new column in Pandas DataFrame based on the existing columns

# importing pandas as pd
import pandas as pd
  
# Creating the DataFrame
df = pd.DataFrame({'Date':['10/2/2011', '11/2/2011', '12/2/2011', '13/2/2011'],
                    'Event':['Music', 'Poetry', 'Theatre', 'Comedy'],
                    'Cost':[10000, 5000, 15000, 2000]})
  
# Print the dataframe
print(df)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Create #column #Pandas #DataFrame #based #existing #columns
ADD COMMENT
Topic
Name
2+1 =