Skip to content

Instantly share code, notes, and snippets.

@shravan-kuchkula
Last active April 19, 2017 14:47
Show Gist options
  • Save shravan-kuchkula/6261f0d8ead65f2393d214d5f01ba1c3 to your computer and use it in GitHub Desktop.
Save shravan-kuchkula/6261f0d8ead65f2393d214d5f01ba1c3 to your computer and use it in GitHub Desktop.
Create a pandas dataframe from a list of dictionaries
# Import the pandas package
import pandas as pd
# Turn list of lists into list of dicts: list_of_dicts
# https://gist.github.com/shravan-kuchkula/6ca3054d5ec0549e1759d739b3d47513
list_of_dicts = [lists2dict(feature_names, sublist) for sublist in row_lists]
# Turn list of dicts into a dataframe: df
df = pd.DataFrame(list_of_dicts)
# Print the head of the dataframe
print(df.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment