Introduction
This article will basically show how to use Pandas library. In the previous article, there is a specific subject about how to install Pandas. It is an article with the title of ‘How to Install Pandas’ where it is available in this link. On the other hand, this article will focus on the usage of Pandas library. Actually, Pandas is a library exist in Python programming language. In short, this Pandas library is very useful when there is a process involving the work with data sets. Why does it very useful for working with data sets ?. The reason is very simple. It is because Pandas library has lots of functions for analyzing, cleaning, exploring and manipulating data sets. Furthermore, the origin of its name is quite simple. Pandas, the name itself has a reference to either “Python Data Analysis” or “Panel Data”. It is also originally created by McKinney in 2008.
In other words, Pandas is a library exist in Python which allows to work with data sets. Using Pandas is very handy for analyzing big data, summarizing conclusions according to numerous statistical theories. Pandas library can also very useful for cleaning unorganized data sets into a reliable data sets for further reading and processing.
How to Use Pandas
As in the previous description exist, there is an explanation in general about how to use Pandas library. One of the explanation exist is analyzing, cleaning, exploring and manipulating data sets. But before going on into those processes, the first step is just to be able to read the data sets. So, the first usage which is available as a function in Pandas library is the function with the ability to read data sets. Another perspective for using Pandas library depends on the data types. According to the type of the data structures where Pandas library can handle, in general there are two types. The first one is Series and the second one is DataFrame. So, using Pandas library can be in a different way depends on the kind of the data structures where the process handled.
How to Read Data Sets Using Pandas
So, the first focus is the ability to be able to read data sets using Pandas. In order to read data sets, just follow the steps below in a sequences :
-
First of all, just execute a command line interface exist in the local device. In this example, since it is a Microsoft Windows operating system, just run the Command Prompt as follows :
Microsoft Windows [Version 10.0.22000.856] (c) Microsoft Corporation. All rights reserved. C:\Users\Personal>
-
Off course, in the next step the most important thing is to have a Python tool or utility exist in the local device. As a reference, just take a look in the article with the title of ‘How to Install Python in Microsoft Windows’ in this link. And also, the article in this link with the title of ‘How to Install Python in Microsoft Windows 11’. If Python tool or utility is already exist, just execute it in the Command Prompt as follows :
Microsoft Windows [Version 10.0.22000.856] (c) Microsoft Corporation. All rights reserved. C:\Users\Personal>python Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
-
First of all, the most important thing is to have Pandas library exist in the local device. It is very simple to list the existing Python library in the local device. An article with the title of ‘How to List Installed Packages and Version using pip tool’ in this link will give an information about that. If Pandas library does not exist in the list, just install it. But for installing it further, just ensure that the ‘Pandas’ library exist for downloading. Read an article in this link with the title of ‘How to Search Package, Module or Library Python using pip_search’ to confirm that. If ‘Pandas’ library exist and available for further download, just install Pandas library in the local device. For achieving that purpose, just try to read the article with the title of ‘How to Install Pandas’ in this link.
-
Soon after, just run the source code for reading data sets using Pandas. The first line is importing the Pandas library as follows :
Microsoft Windows [Version 10.0.22000.856] (c) Microsoft Corporation. All rights reserved. C:\Users\Personal>python Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pandas as pd >>>
-
Continue on to the next step, as an example just use the DataFrame method from a collection data set such as list. Using ‘DataFrame()’ which is available as an attribute from the Pandas library as follows :
Microsoft Windows [Version 10.0.22000.856] (c) Microsoft Corporation. All rights reserved. C:\Users\Personal>python Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pandas as pd >>> list = [1,2,3,4] >>> data_set = pd.DataFrame(list) >>> print(data_set) 0 0 1 1 2 2 3 3 4 >>>