IP - Lab Activity 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

LAB ACTIVITY 4

Write a program in python to create two series objects Obj1 and Obj2 (data given below) and
display the following attributes in the format given below.
Structure of Series objects Output format
Obj1 Obj2 Attribute Name Object 1 Object 2
A 6700 A 640 Data Type
B 5600 B 720 Shape
C 5000 C 1020 No. of Bytes
D 5200 D 437 No. of Dimensions
Item Size
E nil
Has Nans?
Empty
PROGRAM
import pandas as pd
import numpy as np

Obj1 = pd.Series([6700,5600,5000,5200,np.NaN], index=['A', 'B', 'C', 'D', 'E'])


Obj2 = pd.Series([640,720,1020,437], index=['A', 'B', 'C', 'D'])

print("Attribute Name\t\tObject 1\t\tObject 2")


print("_______________________________________________________")
print("Data Type\t\t", Obj1.dtype, "\t\t", Obj2.dtype)
print("Shape \t\t", Obj1.shape, "\t\t\t", Obj2.shape)
print("No. of Bytes\t\t", Obj1.nbytes, "\t\t\t", Obj2.nbytes)
print("No. of Dimensions\t",Obj1.ndim,"\t\t\t",Obj2.ndim)
print("Item Size \t",Obj1.size,"\t\t\t",Obj2.size)
print("Has Nans? \t\t",Obj1.hasnans,"\t\t\t",Obj2.hasnans)
print("Empty \t",Obj1.empty,"\t\t\t",Obj2.empty)
OUTPUT

Attribute Name Object1 Object 2


_________________________________________
Data Type float64 int64
Shape (5,) (4,)
No. of bytes 40 32
No. of Dimensions 1 1
Item Size 5 4
Has Nans? True False
Empty False False

You might also like