0% found this document useful (0 votes)
3 views8 pages

Python 3

Uploaded by

userhdhd443
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views8 pages

Python 3

Uploaded by

userhdhd443
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

3[This P

question paper contains 8 printed pages.]

Your Roll No.

Sr. No. of Question Paper : 1461 F

Unique Paper Code 2342201202

Name of the Paper Data Interpretation and


Visualization using Python

Name of the Course


B.A.(Prog.)
II
Semester :

Duration : 3 Hours Maximum Marks: 90

Instructions for Candidates

1.
Write your Roll No. on the top immediately on receipt
of this question paper.

2. Section A is compulsory
3.
Attempt any 4 (four) questions from Section B.

4.
Parts of a question must be answered together.
Section A

(Compulsory)

1. (a) Write the output of the following code: (3)

P.T.O.
2
1461
np
import numpy
as

a=[Link]([[1,2,3], [3,4,2]], [[4,6,5], [3,1,6]])


4,3)
b=[Link](
print([Link]е)

print([Link])

(b) Explain any two functions that can be used


to create numpy array objects, with suitable
examples. (4)

(c) Consider the given pandas series object and write

the output of the following code statements : (5)

import pandas as pd

obj2=[Link]([4, 6, 5, 8, 7],index=['d', 'b', 'c',

'a', 'e'])

(i) print (obj2['d'])

(ii) print (obj2 [obj2>5])

(iii) print ([Link])

(iv) print (obj2*3)

(v) print (obj2['b': 'a'](

(2)
(d) Write the output of the following code :

import numpy as np

arr = [Link]([3.7, –1.2, –2.6, 0.5, 12.9, 10.1)


1461 3

arr2 = [Link](np.int32)

print(arr2)

series object.
(e) Explain reindex() function for a

(2)

and na_values attr


ibutes of the
(f) Ex pl ai n sk ip ro ws
(3)
read_csv() function.

and string data types


of ndarray
(g) Explain bool
(4)
object.

matplotlib library
in
(h) Write a short note on

(3)
python.

ing code (4)


(i) Write output of the follow
:

import pandas as pd

df = [Link]({'Animal' : ['Falcon', 'Falcon',


'Parrot', 'Parrot'],

., 24., 26.]})
'Max Speed' : [380., 370

]).mean())
print([Link](['Animal'

Section В

(6)
2. (a) Write output of the following code :

P.T.O.
4
1461
pd
import pandas as

d1 = {'Name': ['Pankaj', 'Meghna', 'Lisa'],


'ID': [1, 2, 3],

'Country': ['India', 'India', 'USA'],

'Role": ['CEO', 'СТО', 'СТО']


}

dfl = [Link](d1)

df2 = [Link]({'ID': [1, 2, 3],

'Name': ['Pankaj', 'Anupam', 'Amiť']})

print([Link](df2, on='ID'))

print([Link](df2, on='Name'))
print ([Link](df2, how='left')

(b) Differentiate between loc and iloc operators giving


suitable examples. (4)

(c) Write code in python to create a pandas series


object of all even numbers from 2 to 30, including
2 and 30, using arange(). (5)

3. (a) Explain hierarchical indexing in dataframes.


(4)

(b) Write the names of functions and give example


code for each in matplotlib:
(6)
1461 5

(i) for setting tick labels on x axes

(ii) for adding legend to a plot

(c) Given the code below (5)

import numpy as np

import pandas as pd
data = [Link]([Link](12).reshape((3, 4)).
index=['A', 'B', 'C'], columns=['one', 'two', 'three'.
'four'])

Write the output for following

(i) print(data)
(ii) print([Link]())

(iii) print ([Link](axis= 'columns'))

(iv) print ([Link]())

(v) print ([Link]())

(5)
4. (a) Explain the functions used for :

(i) Removing duplicates in a dataframe

(ii) Filling missing entries in a dataframe

(b) Explain how to create subplots using matplotlib,


with suitable example.
(5)

P.T.O.
1461 6

(c) Explain fillna and


dropna functions in pa
dataframes, with exam ndas
pl e code.
(5)

5. (a) Cons
ider the given dataframe df
and write
the Python statements to perfor
m the following
operations:
(5)

ID marks
B 23 52

A 34 67

C 25 60

(i) Set the title of the row index as name

(ii) Add a column 'semester' with values 2,1,2

(iii) Sort the dataframe in descending order of


the marks column.

(iv) Reindex the dataframe in the order A, B


and C.

(v) Drop the row corresponding to row index

C.

correlation with suitable


(b) Explain covariance and
(5)
examples.

fde [Link] given below and


(c) Consider the as
(5)
answer the following questions.
1461 7

year;qtr1;qtr2;qtr3;qtr4
2019;3000;3200;;3500

2020;2900;-9999;;

2021;1800;2100;1900;1950

2021;1800;2100;1900;1950

2022;1850;-9999;2900;2550

2023;3400;3200;;

(i) Load the file [Link] into a dataframe.

(ii) Fill all the NaN values with 0.

(iii) Remove the duplicate rows from the

original dataframe.

(iv) Replace all the -9999 values with a 0.

(v) Print the average sales made during qtrl


across all the years

6. (a) Write Python statements to plot a horizontal and

vertical bar chart of any assumed dataset. (5)

(b) Write the Python statements to do the following


using matplotlib package: (10)

P.T.O.
8
1461

(i) Plot histogram of different colours of 7


days temperature of your city.

(ii) Set title as "7 Days Temperature".

(iii) Set label for X-axis "Weekdays"

(iv) Set label for Y-axis "Temperature"

(v) Save the image as "[Link]"

7. (a) Writeshort note on histograms and density plots,


with suitable examples.
(4)

(b) Explain the functions : (8)

(i) value_counts()

(ii) stack()

(iii) barh()

(iv) arange()

(c) Write output of the following code : (3)

import pandas as pd

ages=[15, 47, 56, 23, 78, 90]

bins=[12, 30, 70, 95]

categories = [Link](ages, bins)

print(categories)

(1000)

You might also like