Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python | Creating a Pandas dataframe column based on a given condition

# importing pandas as pd
import pandas as pd
  
# Creating the dataframe
df = pd.DataFrame({'Date' : ['11/8/2011', '11/9/2011', '11/10/2011',
                                        '11/11/2011', '11/12/2011'],
                'Event' : ['Music', 'Poetry', 'Music', 'Music', 'Poetry']})
  
# Print the dataframe
print(df)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Python #Creating #Pandas #dataframe #column #based #condition
ADD COMMENT
Topic
Name
6+1 =