0 votes
in Python Pandas by
What are the different ways in which a DataFrame can be created in Pandas?

1 Answer

0 votes
by

Pandas DataFrame is a 2-dimensional labeled data structure with columns of potentially different types. It is generally the most commonly used pandas object.

Pandas DataFrame can be created in multiple ways. Let’s discuss different ways to create a DataFrame one by one.

Creating Pandas DataFrame from lists of lists.

Import pandas library

import pandas as pd

 

# initialize list of lists

data = [[‘tom’, 10], [‘nick’, 15], [‘juli’, 14]]

 

# Create the pandas DataFrame

df = pd.DataFrame(data, columns = [‘Name’, ‘Age’])

 

# print dataframe.

df

...