Q. Use the DataFrame created in Question 9 above to do the following:

a) Display the row labels of Sales.

b) Display the column labels of Sales.

c) Display the data types of each column of Sales.

d) Display the dimensions, shape, size and values of Sales.

e) Display the last two rows of Sales.

f) Display the first two columns of Sales.

g) Create a dictionary using the following data. Use this dictionary to create a DataFrame Sales2.


 

2018

Madhu

160000

Kusum

110000

Kinshuk

500000

Ankit

340000

Shruti

900000

 

 

 

 


 

 

h) Check if Sales2 is empty or it contains data.

 

Answer :-

a =

print(Sales.index)


b =

print(Sales.columns)


c =

print(Sales.dtypes)


d =

print(Sales.shape)
print(Sales.size)
print(Sales.values)


e =

print(Sales.tail(2))


f =

print(Sales[['2014','2015']])


g =

import pandas as pd
inr2018=[160000 ,110000 ,500000 ,340000 ,900000 ]
label=['Madhu','Kusum','Kinshuk','Ankit','shruti']
dic={'2018':inr2018}
Sales2  = pd.DataFrame(dic,index=label)
print(Sales2)


h =

print(Sales2.empty)


Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post