Skip to content

Python Pandas: How to Add an Empty Column to a DataFrame in Pandas

Learn how to add empty columns to a Pandas DataFrame using placeholders like empty strings, np.nan, None, or 0, along with methods like direct assignment, insert(), reindex(), and assign() for precise control.

When working with Pandas DataFrames, you'll often need to add empty columns as placeholders for data that will be populated later - such as computed results, user inputs, or values from another data source. Pandas provides several ways to add empty columns, each using a different placeholder value depending on your needs.

This guide covers the most common methods for adding empty columns and explains when to use each type of placeholder.

Quick Example

The simplest way to add an empty column is direct assignment:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

df['Department'] = ''

print(df)

Output:

      Name  Age Department
0    Alice   25           
1      Bob   30           
2  Charlie   35     

Choosing the Right Placeholder Value

Before adding an empty column, decide what kind of "empty" you need:

Placeholder Syntax Best For
Empty string '' df['col'] = '' Text columns that will be filled with strings
None df['col'] = None Generic null placeholder
np.nan df['col'] = np.nan Numerical columns with missing data
0 df['col'] = 0 Numerical columns with a default of zero

Adding an Empty String Column

Use an empty string when the column will hold text data:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

df['Gender'] = ''
df['Notes'] = ''

print(df)
print("\nData types:\n", df.dtypes)

Output:

      Name  Age Gender Notes
0    Alice   25             
1      Bob   30             
2  Charlie   35             

Data types:
 Name      object
Age        int64
Gender    object
Notes     object
dtype: object

Adding a Column with NaN Values

Use np.nan when the column will contain numerical data with missing values. This is the most common approach for data analysis, as Pandas functions like .mean(), .sum(), and .dropna() handle NaN correctly:

import pandas as pd
import numpy as np

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

df['Score'] = np.nan

print(df)
print("\nData types:\n", df.dtypes)

Output:

      Name  Age  Score
0    Alice   25    NaN
1      Bob   30    NaN
2  Charlie   35    NaN

Data types:
 Name      object
Age        int64
Score    float64
dtype: object

Adding a Column with None

None is a generic Python null value. Pandas converts it to NaN for numeric contexts and keeps it as None for object columns:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

df['Department'] = None

print(df)
print("\nNull check:\n", df.isnull().sum())

Output:

      Name  Age Department
0    Alice   25       None
1      Bob   30       None
2  Charlie   35       None

Null check:
 Name          0
Age           0
Department    3
dtype: int64

Adding a Column at a Specific Position with insert()

By default, new columns are added at the end of the DataFrame. Use .insert() to place a column at a specific position:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

df.insert(0, 'ID', '')

df.insert(2, 'Score', None)

print(df)

Output:

  ID     Name Score  Age
0       Alice  None   25
1         Bob  None   30
2     Charlie  None   35

Syntax: df.insert(position, column_name, value)

Adding Multiple Empty Columns with reindex()

The reindex() method is useful when you need to add several empty columns at once. New columns are filled with NaN by default:

import pandas as pd

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

new_columns = ['Gender', 'Department', 'Salary']
df = df.reindex(columns=df.columns.tolist() + new_columns)

print(df)

Output:

      Name  Age  Gender  Department  Salary
0    Alice   25     NaN         NaN     NaN
1      Bob   30     NaN         NaN     NaN
2  Charlie   35     NaN         NaN     NaN

Adding Multiple Empty Columns with assign()

The assign() method returns a new DataFrame with the added columns, which is useful for chaining operations:

import pandas as pd
import numpy as np

df = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35]
})

df = df.assign(
    Gender=None,
    Score=np.nan,
    Notes=''
)

print(df)

Output:

      Name  Age Gender  Score Notes
0    Alice   25   None    NaN      
1      Bob   30   None    NaN      
2  Charlie   35   None    NaN 

Practical Example: Preparing a Template DataFrame

A real-world use case is creating a DataFrame template with empty columns that will be filled during processing:

import pandas as pd
import numpy as np

df = pd.DataFrame({
    'Student': ['Alice', 'Bob', 'Charlie'],
    'Exam_Score': [85, 92, 78]
})

df = df.assign(
    Grade='',
    Pass_Fail=None,
    Percentile=np.nan
)

df['Grade'] = df['Exam_Score'].apply(
    lambda x: 'A' if x >= 90 else 'B' if x >= 80 else 'C'
)
df['Pass_Fail'] = df['Exam_Score'] >= 60
df['Percentile'] = df['Exam_Score'].rank(pct=True) * 100

print(df)

Output:

   Student  Exam_Score Grade  Pass_Fail  Percentile
0    Alice          85     B       True   66.666667
1      Bob          92     A       True  100.000000
2  Charlie          78     C       True   33.333333

Comparison of Methods

Method Position In Place? Multiple Columns Best For
df['col'] = value End ✅ One at a time Simple, most common
df.insert() Any position ✅ One at a time Precise column placement
df.reindex() End ❌ (returns new) ✅ Multiple Adding many columns at once
df.assign() End ❌ (returns new) ✅ Multiple Method chaining

Conclusion

Adding empty columns to a Pandas DataFrame is straightforward: the key decision is choosing the right placeholder value.

  • Use np.nan for numerical columns, empty strings for text columns
  • Use None as a generic null.
  • For positioning control, use insert(), and for adding multiple columns at once, use reindex() or assign().

These placeholder columns serve as useful templates that can be populated with computed or imported data later in your workflow.

Navigation