Initialize Empty pandas DataFrame in Python (Example Code)

In this article you’ll learn how to create an empty pandas DataFrame in the Python programming language.

Example: Initializing Empty pandas DataFrame Containing Variable Names

import pandas as pd                                   # Load pandas
my_df = pd.DataFrame(columns = ["A", "B", "C", "D"])  # Construct empty pandas DataFrame
print(my_df)                                          # Display empty pandas DataFrame
# Empty DataFrame
# Columns: [A, B, C, D]
# Index: []

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed