Pandas DataFrame & Data Analysis with CSV Files

πŸ”Ή What is Pandas?

Pandas is a powerful Python library for data analysis and manipulation. It provides two main data structures:
  • Series β†’ 1D array with labeled index (like a column)
  • DataFrame β†’ 2D table with rows and columns (like an Excel spreadsheet)
Pandas is used to:
βœ… Read & write data from CSV, Excel, SQL, JSON, etc.
βœ… Perform data cleaning, filtering, sorting, and grouping.
βœ… Handle missing data.
βœ… Perform statistical & numerical operations.
βœ… Merge, join, and reshape datasets.
πŸ“Œ Installing Pandas
To use Pandas, install it using:
pip install pandas

Then import it in Python:

import pandas as pd

πŸ“ Pandas DataFrame

πŸ“Β  Creating a DataFrame Using a List

A DataFrame can be created from a list of lists.

βœ… Example 1: Creating a DataFrame

import pandas as pd data = [['Alice', 25], ['Bob', 30], ['Charlie', 35]] df = pd.DataFrame(data, columns=['Name', 'Age']) print(df)

πŸ“ Creating a DataFrame Using a Dictionary

A DataFrame can be created from a dictionary, where keys represent column names, and values are lists.

βœ… Example 2: Using a Dictionary

data = { "Name": ["Alice", "Bob", "Charlie"], "Age": [25, 30, 35], "City": ["New York", "Los Angeles", "Chicago"] } df = pd.DataFrame(data) print(df)

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.