Last active
April 19, 2017 14:47
-
-
Save shravan-kuchkula/6261f0d8ead65f2393d214d5f01ba1c3 to your computer and use it in GitHub Desktop.
Create a pandas dataframe from a list of dictionaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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