Skip to content

Informatics Practices · Ch 2 — Data Handling using Pandas – I

Introduction to Python Libraries

2.1

Introduction to Python Libraries

Python Libraries: The Foundation

A Python library is a collection of built-in modules that let you perform many actions without writing detailed programs from scratch. Each library contains a large number of modules that you can import and use as needed. For scientific and analytical work, three libraries stand out: NumPy, Pandas, and Matplotlib. These libraries make it easy and efficient to manipulate, transform, and visualise data.

NumPy (Numerical Python)

You encountered NumPy in Class XI. It is a package for numerical data analysis and scientific computing. NumPy uses a multidimensional array object and provides functions and tools for working with these arrays. Because the elements of an array stay together in memory, they can be accessed very quickly.

Pandas (PANel DAta)

Pandas is a high-level data manipulation tool used for analysing data. It has a very rich set of functions that make importing and exporting data extremely easy. Pandas is built on packages like NumPy and Matplotlib, giving you a single, convenient place to do most of your data analysis and visualisation work. Pandas provides three important data structures — Series, DataFrame, and Panel — that make data analysis organised, effective, and efficient.

Matplotlib

Matplotlib is used for plotting graphs and visualisation. With just a few lines of code, you can generate publication-quality plots, histograms, bar charts, scatterplots, and more. It is built on NumPy and is designed to work well with both NumPy and Pandas.

Why Pandas When NumPy Exists?

You might wonder why you need Pandas when NumPy can already handle data analysis. Here are the key differences:

  • Data types: A NumPy array requires homogeneous data (all elements of the same type), while a Pandas DataFrame can hold different data types — float, int, string, datetime, and so on — in different columns.
  • Interface simplicity: Pandas has a simpler interface for common operations like file loading, plotting, selection, joining, and GROUP BY. These features are very handy in data-processing applications.
  • Tracking data: Pandas DataFrames come with column names, making it very easy to keep track of what each column represents.
  • Use case: Pandas is the right choice when your data is in tabular format. NumPy is better suited for numeric array-based data manipulation.