Adding a static constant data column to any Pandas dataframe is simple. As many number of columns can be created by just assigning a value. The constant value is assigned to every row.
Add new data columns
import pandas as pd #load data df1 = pd.read_csv( 'data_deposits.csv' ) print(df1.head(3)) #data column with constant value df1['student'] = False print(df1.head(3))
--[df1 original data]------------------------------- firstname lastname city age deposit 0 Herman Sanchez Miami 52 9300 1 Phil Parker Miami 45 5010 2 Bradie Garnett Denver 36 6300 --[df1 new static data column]----------------------- firstname lastname city age deposit student 0 Herman Sanchez Miami 52 9300 False 1 Phil Parker Miami 45 5010 False 2 Bradie Garnett Denver 36 6300 False -------------------------------------------------------
Here a boolean column was created and all the rows were assigned the same 'False' initial value.
# Python - Delete multiple elements from a list
# SEO Google page rank and web traffic
# Python: Random access generator for multi value sublist yield
# Python: Enumerate counter for loops over list, tuple, string
# Pandas - Read, skip and customize column headers for read_csv
# Pandas - Selecting data rows and columns using read_csv
# Pandas - Space, tab and custom data separators
# Sample data for Python tutorials
# Pandas - Purge duplicate rows
# Pandas - Concatenate or vertically merge dataframes
# Pandas - Search and replace values in columns
# Pandas - Count rows and columns in dataframe
# Pandas - Adding new static columns
# Python - Hardware and operating system information
# Pandas - Remove or drop columns from Pandas dataframe