SeriesPandas is an open source library built for Python programming language. Pandas offers highperformance, easy touse data structure and data analysis tools. Data analysis refers to process of evaluating big data sets using analytical and statistical tools so as to discover useful information and conclusion to support decision making. For working with Pandas, we generally import both pandas and numpy modules/ libraries. import pandas as pdimport numpy as np Before importing pandas or numpy or any other module in pandas you need to install it in your computer from Internet. It is free of cost. The commant to install pandas is: pip install pandas To install numpy in your copmputer give the following command in command prompt: pip install numpy 

Why Pandas Pandas is the most popular library in the Python ecosystem for data analysis. 

Both Series and DataFrame can store Hetrogenious values/ data. 

Creating Series ObjectA series type object can be created using pandas library's Series( ) function. 1. Creating empty Series Object by using just the Series() with no parameter This will create an empty Series type object (obj3) with no values having default data type which is float64. 

2. Creating nonempty Series Object
To create an nonempty Series object, we need to specify arguments for data and indexes: Syntax: <Series object>= pd.Series (data, index) Data is the data part of the Series, it can be any of the following: A Python sequence, An NumPy array, A Python dictionary , A scalar value. Example: obj2= pd.Series ( [3.5, 5.0, 4.5, 8.]) obj1= pd.Series (range(5)) 

Specify data as a scalar value The data can be in form of single value or scalar value. But if data is a scalar value, then the index must be provided. There can be one or more entries in index sequence.
The scalar value (given as data) will be repeated to match the length of index.
The index has to be a sequence of numbers or labels of any type. >>> medalsWon = py.Series (10, index=range(0,1)) >>> medals2= py.Series (15, index=range(1,6,2)) >>> ser3= py.Series ("Hello India ", index =[' Indore','Delhi','Shimla ']) 

Additional FunctionalitySpecifying/Adding NaN values in a Series objectWe can use np.NaN (not a Value) to specify missing or empty value. Legal empty value NaN is defined in NumPy module and hence you can use np.NaN to specify a missing value.


Specifying index( es ) as well as data with Series( ) While creating Series type object we can also provide indexes along with values. Both values and indexes are sequences. 

We can also skip the keyword data, we will get the same output. 

Using a mathematical function/ expression to create data array in Series( ) The Series( ) allows us to define a function/ expression that can calculate for data sequence. 





Accessing a Series Object and its ElementsTo Access Individual Elements of a Series object we have to specify Series object name followed by a dot"." and then the index no whose value we want to access.. 



We can even change indexes of a Series object by assigning new index array to its index attributes. Syntax: <object name>.index= <new index array> Eg ., ob1.index= [a', b', c', d', e'] The Series object's values can be modified but size cannot. So we can say that Series objects are value mutable but sizeimmutable objects. 

The head( ) and tail( ) functionsThe head() function is used to fetch first n rows from a pandas object and tail() function returns last n rows from a pandas object.


When you perform arithmetic operations on two Series type objects, the data is aligned on the basis of matching indexes (this is called Data Alignment in panda objects) and then performed arithmetic; for nonoverlapping indexes, the arithmetic operations result as a NaN (Not a Number) NaN represents missing data. 

Filtering EntriesWe can filter out entries from a Series objects using expression that are of Boolean type. Syntax <Series Object> [<Boolean expression on series object>] e.g ,. Ob1 > 34 When we apply a comparison operator directly on a panda Series object, then it works like vectorized operation and applies this check on each individual element of Series and returns True or False .
BUT when we apply this check with the series object inside [ ], it returns filtered result containing only the values that return True. 

Difference between NumPy Arrays and Series Objects1. In case of ndarrays , we can perform vectorised operations only if the shape of two ndarrays matches, otherwise it returns an error. While in Series for non matching indexes, NaN is returned. 2. In ndarrays , the indexes are always numeric starting from 0 onwards, BUT Series objects can have any type of indexes, including numbers (not necessary starting from 0), letters, labels, string etc. 



Aggregate finctions: >>> obj21= pd.Series ([12,23,45,10,120]) >>> obj21 0 12 1 23 2 45 3 10 4 120 >>> sum(obj21) 210 >>> min(obj21) 10 >>> max(obj21) 120 

Problem1: Object 1 population stored the details of population in four states and object2 AvgIncome stores the total average income reported in previous year in each of these metro . Calculate income per capita for each of these cities.


.Problem 2: Given a Series that stores the area of some states in Km ^{2}. Write code to find the biggest and smallest three area from the given Series. Given Series has been created like this: Ser1= pd.Series ([34567, 890,450,67892, 34677, 78902, 256711,678291, 637632, 25723,2367, 11769, 345, 25671])

