12 Grade Worksheet2

You might also like

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

INDUS UNIVERSAL SCHOOL, SAINIKPURI, SECUNDERABAD

(Sri Lakshmi Saraswathi Educational Society, Affiliated to Central Board of Secondary Education, New Delhi)

Subject: Informatics Practices Class: XI WorkSheet-2__ DataFrames_____________________

1. What is a DataFrame?
2. Write a program in python to create series of given tuple : A = (11, 22, 33, 44, 55)
3. Write a program in Python to create the pandas series of all the characters in the name accepted from
user.
4. Name any two attributes of Series in Python.
5. Write a program to create a series from dictionary that stores classes (6,7,8,9,10) as keys and number of
students as values.
6. Write a program in Python to create a Series in Python from the given dictionary. D = {“Jan” : 31,
“Feb” : 28, “Mar” : 31}
7. Write the output of the following :

import pandas as pd
S1 = pd.Series(12, index = [4, 6, 8])
print(S1)

8. Write the output of the following :

import numpy as num


import pandas as pd
arr=num.array([1,7,21])
S1 = pd.Series(arr)
print(S1)

9. Write the output of the following code :

import pandas as pd
S1 = pd.Series([31, 28, 31, 30, 31], index = ["Jan", "Feb", "Mar", "Apr", "May"])
print("-----------")
print(S1[1:3])
print("-----------")
print(S1[:5])
print("-----------")
print(S1[3:3])
print("-----------")
print(S1["Jan":"May"])

10. Differentiate between Pandas Series and NumPy Arrays.


11. Create the following DataFrame Sales containing year-wise sales figures for five salespersons in INR.
Use the years as column labels, and salesperson names as row labels.

2014 2015 2016 2017

Madhu 100.5 12000 20000 50000

Kusum 150.8 18000 50000 60000

Kinshuk 200.9 22000 70000 70000

Ankit 30000 30000 10000 80000

Shruti 40000 45000 125000 90000

12. Use the DataFrame created in Question 12 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.

You might also like