Search code examples
python-2.7performancedictionarysetdata-cleaning

Python: Opening a set of dictionaries as a dataframe


Most likely a rather basic question, but nevertheless

I have the following raw data file:

[{"column1":"value1","column2":"value2","column3":value3,},{"column1":"value4","column2":"value5","column3":value6},{"column1":"value7","column2":"value8","column3":value9}]

I need to have it as a dataframe in the following form:

   column1  column2  column3
    value1   value2   value3
    value4   value5   value6
    value7   value8   value9

As the file is rather large (1.2 million values over the 3 columns), what would be the fastest and most convenient way of opening it?

Any suggestions on what I should look into are highly appreciated!

Thanks!


Solution

  • From the pandas Documentation (https://pandas.pydata.org/pandas-docs/version/0.21/generated/pandas.DataFrame.html):

    d = {'col1': [1, 2], 'col2': [3, 4]} df = pd.DataFrame(data=d) df