Hello Folks...!!!
Today let us look at the package Pandas in Python.
What is pandas used for ?
It is a powerful data analysis library. It is built over the numpy package. It is very useful to easily carry out data manipulations. The csv files can be loaded to the data structures provided by this library and utilized for machine learning, deep learning or any kind of process. This has two powerful and flexible data structures namely Series and Dataframes.
Installation
Open anaconda prompt and type
pip install pandas or conda install pandas
Pandas Series
The Series are nothing but just one-dimensional arrays. They can hold mixed
data types. They can be thought of like one-dimensional lists in Python but
with some new features. Let us learn them one by one with examples.
Building a series
Method 1: Import the pandas library and use the series method
(constructor)
Method 2: Directly import the Series from pandas package and use it with
some new name
Accesing the series elements
The index of the Series starts from 0 and ends with n-1. The
elements of the Series can be accessed using these indices. The elements are
mutable ie., they can be changed through the code at any instant. Look at
the example below.
Customizing the index
The index can be customized which provision is not available with the lists.
It has to be passed as parameter to the Series() method.
Converting other objects
Other Python objects like lists, dictionaries and tuples can also be converted into Series. Look at the example below. For the dictionary object, the key will be considered as the index. For rest one can choose between default and customized index.
Output :
Thanks a lot. If you want me to write on any topics, lemme know!!
ReplyDelete