Creating a Pandas DataFrame from a Python Generator
Python - Import and Export
In this example we create a dataframe from a Python generator that takes numbers from 1 to 10 and also returns the square of those numbers.
import pandas generator = ((i,i**2) for i in range(1,11)) df = pd.DataFrame(generator,columns=['number','number_squared']) df.head(10)
By analyseup - Last Updated Sept. 22, 2021, 4:21 p.m.