Using a list of dictionaries

When a list of dictionaries is converted to a DataFrame, each dictionary in the list corresponds to a row in the DataFrame and each key in each dictionary represents a column label.

Let's define a list of dictionaries:

demographicData = [{"Age": 32, "Gender": "Male"}, {"Race": "Hispanic", "Gender": "Female", "Age": 26}]

Now the list of dictionaries can be converted to a DataFrame as shown in the following code:

demographicDF = pd.DataFrame(demographicData)

The following is the output:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset