Pandas Data Structure (Python Pandas -I ) | Data Handling Using Pandas | Class 11 | Class 12 | CBSE | Informatics Practices | Notes | Study Material

Pandas Data Structure

Data Structure:

    A data structure is a particular way of storing and organizing data in a computer to suit a specific purpose so that it can be accessed and worked with in appropriate ways.

    Two Basic data Structures:
        1. Series
        2. DataFrame
        3. Panel

Series Vs DataFrame:

Property

Series

DataFrame

Dimensions

1 - Dimensional

2-Dimentional

Type of data

1.Homogeneous

2.All the elements must be of same type in a series object

1.Heterogenoues

2.DataFrame object can have elements of different data types

Mutability

Values Mutable: Their elements value can change

Size-immutable, i.e., size of a Series object, once created, cannot change. If you want to add/drop an element, internally a new Series object will be created.

 

Values Mutable: Their elements value can change

Size-mutable, i.e., size of a DataFrame object, once created, can change in place. That is, you can add/drop elements in an existing DataFrame object.


import both pandas and numpy modules/libraries by giving following import statements


import pandas as pd
import numpy as np


Module
  • A module is a single file (or script) that contains Python code. This file could include functions, classes, variables, and runnable code. Essentially, a module is a file that you can import and use in your own Python programs.
  • Example:
  • math is a module that provides mathematical functions like sqrt() and sin().
  • pandas itself is a module.
Library
  • A library is a collection of modules that are grouped together to provide specific functionality. A library can contain one or more modules, and it’s essentially a broader package of tools that you can use in your programs.
  • Example:
  • Pandas is a library, and within it, there are multiple modules (like pandas.core, pandas.io, etc.).
Key Difference:
  • Module: A single file of code (e.g., pandas.py).
  • Library: A collection of modules (e.g., the entire pandas library includes many modules).

In Python, the terms module and library are often used interchangeably, but they have slightly different meanings. Here's a simple explanation:



Post a Comment

0 Comments