Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to add column to the Dataframe in python

#using the insert function:
df.insert(location, column_name, list_of_values) 
#example
df.insert(0, 'new_column', ['a','b','c'])
#explanation:
#put "new_column" as first column of the dataframe
#and puts 'a','b' and 'c' as values

#using array access:
df['new_column_name'] = value
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #column #Dataframe #python
ADD COMMENT
Topic
Name
4+8 =