How to create an empty dataframe

I saw this line of code from a book, what does that mean? After that, I print portfolio, it is just a underscore, but it is not empty DataFrame.

portfolio = portfolio = pd.DataFrame()


You’re seeing the result of how an empty DataFrame is displayed,. The DataFrame is in fact empty; you can see this better using a print or checking the empty attribute.

import pandas as pd
df = pd.DataFrame()


#Empty DataFrame
#Columns: []
#Index: []


Leave a Reply

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