Programming Essentials Python - Overview of Pandas Libraries - Creating Data Frames from lists

In this article, we will explore how to create DataFrames using Pandas, a two-dimensional labeled array that can store data of any data type. We will cover creating DataFrames from lists of tuples and lists of dictionaries, providing step-by-step instructions and code examples for each method.

Key Concepts Explanation

Creating Data Frames from lists

Pandas Data Frame is a two-dimensional labeled array capable of holding attributes of any data type. It is similar to a multi-column Excel spreadsheet or a database table. We can create Data Frames using a list of tuples or a list of dictionaries.

import pandas as pd

sals_ld = [(1, 1500.0), (2, 2000.0, 10.0), (3, 2200.00)]
sals_df = pd.DataFrame(sals_ld)

Creating Pandas Data Frame using list of dicts

When creating DataFrames using a list of dictionaries, the column names will be inherited automatically using keys from the dictionary.

sals_ld = [
    {'id': 1, 'sal': 1500.0},
    {'id': 2, 'sal': 2000.0},
    {'id': 3, 'sal': 2200.0}

sals_df = pd.DataFrame(sals_ld)

Hands-On Tasks

  1. Create a Pandas Data Frame using a list of tuples with two columns.
  2. Create another Pandas Data Frame using a list of dictionaries with different keys and values.


In this article, we have covered the basics of creating DataFrames in Pandas using lists of tuples and dictionaries. We encourage you to practice these concepts and engage with the community for further learning.

[Click here to watch the video tutorial](put your video link placeholder here)

Watch the video tutorial here