How to create a new blank dataframe in Pandas ?

Pandas is a software library written for the Python programming language for data manipulation and analysis.

Dataframe is a 2-d labelled data structure consists of columns of different types. You can think of it like a spreadsheet.

Creation of an empty dataframe

Creating a new blank data frame is very simple. You just need to use DataFrame method of pandas library and pass an array of columns to it, like this :

column_names = ["Column 1",  "Column 2", "Column 3"]

df_newFrame = pd.DataFrame(columns = column_names)

df_newFrame

Adding new data to dataframe

To add data into this newly created dataframe, you need to do the following

ignore_index=True ‘ignores’, meaning doesn’t align on the joining axis. it simply pastes them together in the order that they are passed

df_newFrame.append({"Column 1" : "foo",  "Column 2" : 100, "Column 3" : 150.01}, ignore_index=True)
output

Subscribe now. Stay updated.

Happy Learning 🙂

Leave a Reply