Thursday, June 10, 2021

How To Convert Python List To Pandas DataFrame

How To Convert Python List To Pandas Dataframe

Pandas dataframe is a very useful data structure.

In this notebook, I will show with examples how to convert Python List to Pandas Dataframe.

In [2]:
import pandas as pd
Convert List to Dataframe

Let us create a dummy list of stock symbols.

In [49]:
stocks = ['AMC', 'GME', 'BB', 'CLOV', 'PLTR']

Creating Dataframe from list can be achieved using pandas.DataFrame.

In [32]:
df = pd.DataFrame(stocks,columns=['ticker'])

Let us look at our dataframe now.

In [33]:
df.head()
Out[33]:
ticker
0 AMC
1 GME
(continued...)

from Planet SciPy
read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...