Pandas dataframe from list of lists
Problem
Sometimes you’re working with lists of lists and you want to transform them into a Pandas dataframe to make some data analysis with it.
Solution
Pandas has a special constructor just for this use case:
# Import pandas library
import pandas as pd
# List of lists
data = [['Value 1', 10], ['Value 2', 15], ['Value 3', 20]]
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['Value', 'Number'])
# print dataframe
print(df)