⊕
⊖
Contents
Pandas – Create an empty DataFrame with specific column names
To create an empty DataFrame in Pandas, call DataFrame() class constructor with the list of column names passed as argument for columns named parameter.
Syntax
The syntax of DataFrame() class with columns parameter is
DataFrame(columns=None)
Examples
1. Create an empty DataFrame
In this example, we create an empty DataFrame with specific column names using DataFrame().
Python Program
import pandas as pd
df = pd.DataFrame(columns=['name', 'age', 'country'])
print(df)
Run Code CopyOutput
Empty DataFrame
Columns: [name, age, country]
Index: []
Summary
In this Pandas Tutorial, we learned how to create an empty DataFrame with specific column names.
Next Topic ⫸ Pandas DataFrame – Create from dictionary
⫷ Previous Topic Pandas – Create empty DataFrame