Panda:
It has a DataFrame object with customized indexing
We can perform aggregations & Transformations on the data sets
It is used for data alignment & integration of the missing data
Process a variety of data sets in different formats like matrix data, tabular, heterogeneous, time series
Handling multiple operations of the datasets such as subsetting, slicing. Filtering, group by, re-ordering, and re-shaping
It integrates with the other libraries such as Scipy, and scikit-learn.
Data Structures in Pandas
There are 2 types of data structures in Pandas
Series (1D Array)
Data Frame
Series:
Series is 1-dimensional array to hold different types of values
We can create Series by using arrays, dictionary & scalar values
Salary: floating point.
pandas.Series(data,index)
Data Frame:
Data Frame is a two-dimensional array.
It contains heterogeneous Data
Data Frame has labelled rows & columns.
We can create data frame using list, dictionary, arrays etc.
Function used: pandas.DataFrame()


We create an empty data frame.

Write a program to print the area of two rectangles having sides (4,5) and (5,8) respectively by creating a class named ‘Rectangle’ with a method named ‘Area’ which returns the area and length and breadth passed as parameters.

Create a class BankAccount with attributes cust_name, cust_no and balance. __init__() should initialize cust_no and cust_name by reading from the user; initialize balance to Zero. Create methods deposit() AND withdraw() to change the balance. Create a method to print the details.

Create a class Baby with attributes name, DoB, poliodate and bcgdate. Create __init__() to initialize the attributes and print details using another method.

Polymorphism
Sub class can inherit from the sub-class.
class Student() :
def __init__(self,prn,name) :
self.prn=prn
self.name=name
def speak(self) :
print(‘My name is {}’’.format(self.name))
print(‘’I am DSDA semester 1 student’’)
class AR(Student):
def speak(self) :
print(‘’My name is {}’’.format(self.name))
print(‘’I am AR of DSDA sem 1’’)
class CR(Student):
def speak(self) :
print(‘’My name is {}’’.format(self.name))
print(‘’I am CR of DSDA sem 1’’)
S1=Student(‘‘101’’, ‘‘Aklant’’)
S2=AR(‘‘102’’, ‘‘Palak’’)
S1.speak() #Depends on from where it is being called.
S2.speak()
S3.speak()
An object is passed to the check function.
Def check (obj) :
Print(obj)
Obj.speak()
Check(nisha)
Check(S1)
Check(S2)
Check(S3)
Define three classes:Bear, Rabbit and Octothorpe. For each define one method eats(). This should print “berries” for Bear, “Clover” for Rabbit”Campers” for Octothorpe. Create one object for ach and print what it eats.
class Bear():
def eats(self) :
print(‘‘I am bear, I eat berries’’))
class Octothorpe(Student):
def eats(self) :
print(‘I am {}’’.format(eats.Octothorpe)
class Rabbit(Student):
def eats(self) :
print(‘I am {}’’.format(eats.Rabbit)
S1=Student(‘‘101’’, ‘‘Aklant’’)
S2=AR(‘‘102’’, ‘‘Palak’’)
s1.speak() #Depends on from where it is being called.
s2.speak()
s3.speak()
Create three classes, a superclass called “Characters” that will be defined with the following attributes and methods: Attributes: name, team, height, weight and Methods: sayHello() . The other two classes, which will be subclasses, will be “GoodPlayers” and “BadPlayers.” Both classes will inherit “Characters” and super all the attributes that the superclass requires. The subclasses do not need any other methods or attributes. The team attribute should be declared to a string of either “good” or “bad.” The sayHello() should output the statement “Hello, my name is <name> and I’m on the <team>”. Instantiate one player on each team, and call the sayHello method for each. The output should result in the following:
>>> “Hello, my name is Max and I’m on the good guys”
>>> “Hello, my name is Tony and I’m on the bad guys”
Sub class can inherit from the sub-class.
class Characters() :
def __init__( name,team,height,weight) :
self.team=team
self.name=name
self.height=height
self.weight=weight
def sayHello(name,team,height,weight) :
print(‘‘Hello, my name is {} and I’m on the {}”.format(self.name ,self.team)
class GoodPlayers(Characters):
def speak(self) :
print(‘‘Hello, my name is {} and I’m on the {}’’)
print(‘’I am AR of DSDA sem 1’’)
class BadPlayers(Characters)
def speak(self) :
print(‘’My name is {}’’.format(self.name))
print(‘’I am CR of DSDA sem 1’’)
S1=Student(‘‘101’’, ‘‘Andy’’)
S2=AR(‘‘102’’, ‘‘Palak’’)
S1.sayHello()