Introduction to Series and DataFrames in Python Pandas| Data science full course free

In the Introduction to Pandas post, we learned about Pandas. In today's post we will learn Data Structures in Python Pandas.


So, without consuming much time, let's jump to the introduction:-

Data Structures in Pandas Python

Pandas deals with 2 Data structures:-

  1. Series
  1. DataFrame

Before the latest updates, Python had 3. Panel() data structure which is used for the 3-D array. But Pandas has removed its Panel() and now it only has Series and DataFrame left.

These data structures are built with NumPy which means they are fast.

Dimension and Description of Data Structure

The best way to think of these data structures is that the higher dimensional data structures is a container of its lower-dimensional data structure which means DataFrame is a container for Series.

Building and handling two or more dimensional array is tedious task, burden is placed on the user to consider the orientation of the Data Sets when writing functions.

Mutability of the Data Structures

1. Value Mutable

        Pandas provides mutabily of values in both data structures. That means values of arrays in both Series as well as DataFrame are mutable.

2. Size Mutable

        The size of the DataFrame is mutable but the size of the Series is immutable. 

Let us understand the both Data Structure one by one:-

Pandas Series

Series is a one-dimensional labeled array in Python Pandas which is capable of holding data of any type i.e. integer, float, characters, etc. The axis labels are collectively called index. Series is a homogeneous data structure.

We can create series both row-wise or column-wise.

Let us understand it by simple Example:-


In the above picture, we created Series and store it into data variable and print the data. From the output it is clear that it passes index values too.

points to remember

  • It is homogeneous in nature
  • It is size immutable
  • But values are mutable

You can read more about Pandas Series in Introduction to Series in Python Pandas


Pandas DataFrame

DataFrame is widely used and one of the most important data structures. It can contain both NumPy arrays as well as Series Data Structure. DataFrame is a two-dimensional array with heterogeneous data. We can pass Integer and string in a single DataFrame.

Let us understand it by code:-


In the above DataFrame, we created DataFrame with index and column names. We will discuss it in the next video and BlogPost tutorial.

Points to be remember

  • It is heterogeneous in nature
  • It is Size Mutable
  • It is value Mutable


I hope you loved this post. Kindly Subscribe to our Youtube channel - Codin India
where we will learn Data Science with Python in Hindi and many more.


If you want to learn Data Science in Hindi click -> Data Science Full Course in Hindi

If you want to learn Numpy in Hindi click -> NumPy Tutorial

If you want to learn Full Stack web development in Hindi click -> Full Stack Web Development in Hindi

If you want to learn Python Programming click -> Python Programming in Hindi

Comments

Post a Comment