HOWTO · Pandas
How to Create an Empty Column in Pandas DataFrame
We can add an empty column to DataFrame in Pandas using simple assignment operator, reindex(), assign() and insert() methods.
On this page
To add an empty column to an existing pandas DataFrame in Python, use df["NewColumn"] = "" for blank text, or df["NewColumn"] = float("nan") for missing values (NaN). Both preserve existing rows and other columns. A blank string is a text value, so choose the representation your later calculations and filtering need.
Use reindex() to add several columns, assign() to return a DataFrame with named additions, or insert() to control placement. The examples require pandas and NumPy.
Create Empty Column Pandas With the Simple Assignment
Assigning a scalar to a new column repeats that value for every existing row. Assignment changes df directly and appends a new column on the right. If the name already exists, assignment replaces its contents, so use a fresh name when preserving data.
This example compares a blank string, NumPy’s missing-value marker, and an empty pandas Series:
import pandas as pd
import numpy as np
dates = ["April-20", "April-21", "April-22", "April-23", "April-24", "April-25"]
income = [10, 20, 10, 15, 10, 12]
expenses = [3, 8, 4, 5, 6, 10]
df = pd.DataFrame({"Date": dates, "Income": income, "Expenses": expenses})
df["Empty_1"] = ""
df["Empty_2"] = np.nan
df["Empty_3"] = pd.Series()
print(df)
Output:
Date Income Expenses Empty_1 Empty_2 Empty_3
0 April-20 10 3 NaN NaN
1 April-21 20 8 NaN NaN
2 April-22 10 4 NaN NaN
3 April-23 15 5 NaN NaN
4 April-24 10 6 NaN NaN
5 April-25 12 10 NaN NaN
Empty_1 contains blank strings, while Empty_2 contains NaN. When assigning a Series, pandas aligns its index labels with the DataFrame’s row labels. The empty Series has no matching labels, so Empty_3 also contains missing values throughout.
For an explicitly typed alternative, use df["NewColumn"] = pd.Series(index=df.index, dtype="float64"). Including df.index makes the intended row alignment explicit. To select missing entries later, use df["NewColumn"].isna() rather than equality comparisons with NaN; blank strings require a separate comparison with "".
pandas.DataFrame.reindex() Method to Add an Empty Column in Pandas
The pandas.DataFrame.reindex() method returns a DataFrame with the requested column labels and order. Newly introduced labels receive missing values by default. Be careful: columns specifies the entire resulting column list, not just additions.
import pandas as pd
import numpy as np
dates = ["April-20", "April-21", "April-22", "April-23", "April-24", "April-25"]
income = [10, 20, 10, 15, 10, 12]
expenses = [3, 8, 4, 5, 6, 10]
df = pd.DataFrame({"Date": dates, "Income": income, "Expenses": expenses})
column_names = ["Empty_1", "Empty_2", "Empty_3"]
df = df.reindex(columns=column_names)
print(df)
Output:
Empty_1 Empty_2 Empty_3
0 NaN NaN NaN
1 NaN NaN NaN
2 NaN NaN NaN
3 NaN NaN NaN
4 NaN NaN NaN
5 NaN NaN NaN
Here the result retains the six row labels but drops Date, Income, and Expenses. Reassigning that result to df replaces the original reference.
To retain the original data, start with df.columns.tolist() and append the new names. This preserves the order of the existing columns and places the additions on the right. Store the returned DataFrame because this method does not modify the original object in place. Run this example:
import pandas as pd
import numpy as np
dates = ["April-20", "April-21", "April-22", "April-23", "April-24", "April-25"]
income = [10, 20, 10, 15, 10, 12]
expenses = [3, 8, 4, 5, 6, 10]
df = pd.DataFrame({"Date": dates, "Income": income, "Expenses": expenses})
df = df.reindex(columns=df.columns.tolist() + ["Empty_1", "Empty_2", "Empty_3"])
print(df)
Output:
Date Income Expenses Empty_1 Empty_2 Empty_3
0 April-20 10 3 NaN NaN NaN
1 April-21 20 8 NaN NaN NaN
2 April-22 10 4 NaN NaN NaN
3 April-23 15 5 NaN NaN NaN
4 April-24 10 6 NaN NaN NaN
5 April-25 12 10 NaN NaN NaN
The original dates, income, and expenses remain, followed by three columns containing NaN. Choose new names that are not already present to avoid requesting duplicate labels.
pandas.DataFrame.assign() to Add an Empty Column in Pandas DataFrame
The pandas.DataFrame.assign() method returns a DataFrame with one or more named columns. Each keyword names a column and supplies its values. Keep the returned object, as shown by df = df.assign(...), or store it under another name to retain the original DataFrame.
import pandas as pd
import numpy as np
dates = ["April-20", "April-21", "April-22", "April-23", "April-24", "April-25"]
income = [10, 20, 10, 15, 10, 12]
expenses = [3, 8, 4, 5, 6, 10]
df = pd.DataFrame({"Date": dates, "Income": income, "Expenses": expenses})
df = df.assign(Empty_1="", Empty_2=np.nan)
print(df)
Output:
Date Income Expenses Empty_1 Empty_2
0 April-20 10 3 NaN
1 April-21 20 8 NaN
2 April-22 10 4 NaN
3 April-23 15 5 NaN
4 April-24 10 6 NaN
5 April-25 12 10 NaN
Empty_1 contains blank strings; only Empty_2 contains NaN. The existing columns remain. As with direct assignment, specifying an existing column name replaces that column in the returned DataFrame.
pandas.DataFrame.insert() to Add an Empty Column to a DataFrame
Use pandas.DataFrame.insert() when placement matters. Call it as df.insert(loc, column, value): loc is a zero-based column position, column is the new label, and value is required. Supply "" for blank text or np.nan for missing values.
The position must be between 0 and len(df.columns), inclusive; the upper limit appends the column. By default, inserting an existing label fails. Passing allow_duplicates=True permits a duplicate label but can make later column selection ambiguous.
Unlike assign() and reindex(), insert() changes df in place and returns None. Do not write df = df.insert(...).
The following example appends two columns:
import pandas as pd
import numpy as np
dates = ["April-20", "April-21", "April-22", "April-23", "April-24", "April-25"]
income = [10, 20, 10, 15, 10, 12]
expenses = [3, 8, 4, 5, 6, 10]
df = pd.DataFrame({"Date": dates, "Income": income, "Expenses": expenses})
df.insert(3, "Empty_1", "")
df.insert(4, "Empty_2", np.nan)
print(df)
Output:
Date Income Expenses Empty_1 Empty_2
0 April-20 10 3 NaN
1 April-21 20 8 NaN
2 April-22 10 4 NaN
3 April-23 15 5 NaN
4 April-24 10 6 NaN
5 April-25 12 10 NaN
Empty_1 occupies column position 3 and contains blank strings. After that insertion, position 4 is available for Empty_2, which contains NaN. To place a column first instead, use loc=0; existing columns shift right without changing their values.