How to create an empty DataFrame with specific column names?
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)
Output
Empty DataFrame
Columns: [name, age, country]
Index: []
Summary
In this Pandas Tutorial, we learned how to create an empty DataFrame with specific column names.