A sneak peek on PANDAS..!

“Never stop learning because life never stops teaching.”

Sandhiya M
5 min readApr 13, 2022

➥ Hey everyone, in this blog, we will be discussing Pandas in Python. Before talking about Pandas, one must understand the concept of Numpy arrays.

➥ Why? Because Pandas is an open source software library which is built on top of Numpy. In this Python Pandas Tutorial, I will take you through the topics, which will serve as fundamentals.

Let’s get started. :-)

What is Python Pandas?

Pandas is used for data manipulation, analysis and cleaning. Python pandas is well suited for different kinds of data, such as:

  • Tabular data with heterogeneously-typed columns
  • Ordered and unordered time series data
  • Arbitrary matrix data with row & column labels
  • Unlabelled data
  • Any other form of observational or statistical data sets.

➱ And what’s really interesting with pandas is that many other packages are hidden in it. Pandas is a core package with additional features from a variety of other packages. And that’s great because you can work only using pandas.

  • pandas is like Excel in Python: it uses tables (namely DataFrame) and operates transformations on the data. But it can do a lot more.

How to install Pandas?

Don’t ask me why “pd” and not “p” or any other, it’s just like that. Deal with it :)

To install Python Pandas, simply import it by typing: “import pandas as pd”.

Moving ahead in Python pandas tutorial, let’s take a look at some of its operations:

Python pandas operations:

Using Python pandas, you can perform a lot of operations with series, data frames, missing data, group by etc.

Now, let us understand all these operations one by one.

What is a Pandas Series?

◈A Pandas Series is like a column in a table.

◈It is a one-dimensional array holding data of any type.

What is a Pandas Data Frame?

→ A Pandas Data Frame is a 2 dimensional data structure, like a 2 dimensional array, or a table with rows and columns.

Indexing in pandas:

ADDING A NEW COLUMN:

➥If you want the first two rows of the data, type in the below command:

◉data.head(2)

➥Similarly, if you want the last two rows of the data, type in the below command:

◉data.tail(2)

What Describe() does:

➤ It is a method returns description of the data in the DataFrame.

➤ If the DataFrame contains numerical data, the description contains these information for each column:

Select Data From Pandas Dataframes:

Location-based Indexing:

➠After working with indexing for Python lists and numpy arrays, you are familiar with location-based indexing. You already know that Python location-based indexing begins with [0], and you have learned how to use location-based indexing to query data within Python lists or numpy arrays.

➠You can use location-based indexing to query pandas dataframes using the attribute .iloc and providing the row and column selection as ranges (i.e. start and stop locations along the rows and columns). Just like with numpy arrays, the range provided is inclusive of the first value, but not the second value.

Example 1:

Explanation: It prints only the stud1 and stud2 data.

Example 2:

Explanation: It prints only the stud1 , stud2 and stud3 data.

Label-based Indexing:

Pandas dataframes can also be queried using label-based indexing.

➠This feature of pandas dataframes is very useful because you can create an index for pandas dataframes using a specific column (i.e. label) that you want to use for organizing and querying your data.

➠ For example, you can create an index from a specific column of values, and then use the attribute .loc to select data from the pandas dataframes using a value that is found in that index

Conclusion

In this article, I have presented some of my best tips for learning PANDAS concepts.

★ If you really want to become a programmer or add a coding skill to your skills, learning Python is a great place to start. I recommend that you learn the basics with an interactive course before moving on to more difficult concepts. Take notes and make sure to review them regularly and try to practice writing code as often as possible.

★ Connect with your colleagues and start helping others when they have problems that can be a great review, and working with someone else’s code is a great way to learn new things.

If you do all of this, nothing can stop you!…Will catch you all with the next blog.

If you liked then appreciate the writing, 👏👏 clap, and share.

You can connect with me on LinkedIn.

--

--