How to add Empty Column to Dataframe in Pandas?
Last Updated :
05 May, 2025
In Pandas we add empty columns to a DataFrame to create placeholders for future data or handle missing values. We can assign empty columns using different methods depending on the type of placeholder value we want. In this article, we will see different methods to add empty columns and how each one works.
Lets see an example where we will add an empty column with an empty string (' '). We will be using Numpy and Pandas libraries for its implementation.
Python
import pandas as pd
Mydataframe = pd.DataFrame({'FirstName': ['Ansh', 'Ashish', 'Milan'],
'Age': [21, 22, 23]})
print("---Original DataFrame---\n", Mydataframe)
Mydataframe['Gender'] = ''
Mydataframe['Department'] = ''
print("---Updated DataFrame with Empty Strings---\n", Mydataframe)
Output:
Empty StringSyntax:
DataFrame['NewColumn'] = value
Where value can be:
- ' ' for an empty string
- None for null values
- np.nan for missing numerical values
Lets see more examples of this:
Example 1: Adding an Empty Column with NaN
When dealing with numerical data or missing values NaN values is a commonly used. We need to import NumPy to use np.nan.
Python
import numpy as np
Mydataframe['Gender'] = ''
Mydataframe['Department'] = np.nan
print("---Updated DataFrame with NaN---\n", Mydataframe)
Output:
Empty Column with NaNExample 2: Adding an Empty Column with None
None is useful when we want a placeholder that represents a "null" or missing data.
Python
Mydataframe['Gender'] = None
Mydataframe['Department'] = None
print("---Updated DataFrame with None---\n", Mydataframe)
Output:
Empty Column with NoneExample 3: Adding Empty Columns Using Dataframe.reindex()
We can use the reindex() method to add new columns with NaN values by default. For example we have created a Pandas DataFrame with two columns "FirstName" and "Age". We will apply Dataframe.reindex() method to add two new columns "Gender" and " Roll Number" to the list of columns with NaN values.
Python
import pandas as pd
Mydataframe = pd.DataFrame({'FirstName': ['Preetika', 'Tanya', 'Akshita'],
'Age': [25, 21, 22]})
print("---Original DataFrame---\n", Mydataframe)
Mydataframe = Mydataframe.reindex(columns=Mydataframe.columns.tolist() + ['Gender', 'Roll Number'])
print("---Updated DataFrame with reindex()---\n", Mydataframe)
Output:
Using Dataframe.reindex()Example 4: Adding Empty Columns Using insert()
The insert() method adds a new column at a specified position in the DataFrame. In this example we will add an empty column of "Roll Number" using Dataframe.insert().
Python
Mydataframe = pd.DataFrame({'FirstName': ['Rohan', 'Martin', 'Mary'],
'Age': [28, 39, 21]})
print("---Original DataFrame---\n", Mydataframe)
Mydataframe.insert(0, 'Roll Number', '')
print("---Updated DataFrame with insert()---\n", Mydataframe)
Output:
Using insert()With these simple methods we can easily add empty columns to our DataFrame for placeholders for future data or handling missing values as needed.
Similar Reads
Pandas Append Rows & Columns to Empty DataFrame Appending rows and columns to an empty DataFrame in pandas is useful when you want to incrementally add data to a table without predefining its structure. To immediately grasp the concept, hereâs a quick example of appending rows and columns to an empty DataFrame using the concat() method, which is
4 min read
How to add column from another DataFrame in Pandas ? In this discussion, we will explore the process of adding a column from another data frame in Pandas. Pandas is a powerful data manipulation library for Python, offering versatile tools for handling and analyzing structured data. Add column from another DataFrame in Pandas There are various ways to
6 min read
Add zero columns to Pandas Dataframe Prerequisites: Pandas The task here is to generate a Python program using its Pandas module that can add a column with all entries as zero to an existing dataframe. A Dataframe is a two-dimensional, size-mutable, potentially heterogeneous tabular data.It is used to represent data in tabular form lik
2 min read
How to Delete a column from Pandas DataFrame Deleting data is one of the primary operations when it comes to data analysis. Very often we see that a particular column in the DataFrame is not at all useful for us and having it may lead to problems so we have to delete that column. For example, if we want to analyze the students' BMI of a partic
2 min read
Add column names to dataframe in Pandas Sometimes, Pandas DataFrames are created without column names, or with generic default names (like 0, 1, 2, etc.). Let's learn how to add column names to DataFrames in Pandas. Adding Column Names Directly to columns Attribute The simplest way to add column names is by directly assigning a list of co
3 min read