0% found this document useful (0 votes)
57 views5 pages

Holidays Homework - Ip

The document contains holiday homework assignments for Class XII in the subject of Information Practices, focusing on DataFrames and Series in Python's pandas library. It includes tasks such as creating DataFrames from various data structures, performing operations on DataFrames, and writing Python code to manipulate data. The assignments are structured in a question format, guiding students to apply their knowledge of pandas to solve practical problems.

Uploaded by

onurashi2900
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)
57 views5 pages

Holidays Homework - Ip

The document contains holiday homework assignments for Class XII in the subject of Information Practices, focusing on DataFrames and Series in Python's pandas library. It includes tasks such as creating DataFrames from various data structures, performing operations on DataFrames, and writing Python code to manipulate data. The assignments are structured in a question format, guiding students to apply their knowledge of pandas to solve practical problems.

Uploaded by

onurashi2900
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
You are on page 1/ 5

Holiday Homework-1

Class : XII Subject: IP Practical file assignment -2 Topic:DataFrame

Q1. Create following Dataframe Hospital from a 2D dictionary having value as lists:

Q2. Create following Dataframe Sales from a 2D dictionary having values as dictionary objects:

Yr1 Yr2
Qtr1 34500 44900
Qtr2 56000 46100
Qtr3 47000 57000
Qtr4 49000 59000

Q3. Create following Dataframe topdf from a 2D list having dictionaries as its elements.

Rollno Name Marks


0 115 Pavni 97.5
1 236 Rishi 98.0
2 307 Preet 98.5
3 422 Parul 98.0

Q4. Write a program to create following Dataframe from a 2D list.

Zone1 Zone2 Zone3 Zone4


Target 56000 70000 75000 60000
Sales 58000 68000 78000 61000

Q5. Write a program to create a Dataframe from a 2D array as shown below:

101 113 124


130 140 200
115 216 217
Q6. Write a Python code to create a DataFrame ‘temp’ by using Series method:

city Maxtemp Mintemp Rainfall


0 Delhi 40 32 24.1
1 Bengaluru 31 25 36.2
2 Chennai 35 27 40.8
3 Mumbai 29 21 35.2
Q7. Create following DataFrame df using following data:

(a) Add a column called E with the following data: [14,220].


(b) Add a new record with appropriate values.
(c) Remove the column A, C.
(d) Remove first and second rows from DataFrame.

Q8. Create following Dataframe df1 :

1) Display all the product details of record no 102,104 and 106.


2) Display product and company details of 101 and 104 records of DataFrame df1
3) Display first record and third record of DataFrame df1.
4) Display quantity and company details of all records of DataFrame df1.
5) Change the salary of record no.104 to 50000.
6) Display the details of record no 104
7) Change the company name to acer and quantity to 400 of record no 101 and 102.
8) Add new record ["mic","dell",100,450] into DataFrame df1.

Q9. Create following DataFrame batsman.

Do following operation
1) Add score1 and score2 and assign it to column total
2) Display lowest score of score1.
3) Display highest score of score2
4) change index to player1,player2, player3,player4
5) Display all the details of DataFrame whose score1 <75
6) Display only name of DataFrame whose score1 <75
7) Display name and score1 of DataFrame whose score1 <75
8) Display DataFrame in descending order of score2
9) Change the column name to batsmanno,bname, s1 ,s2 and sum of DataFrame
10)Add 5 score to those who have more than 75 score2

Q10. Write the code in pandas to create the following DataFrames:

Write the commands to do the following operations on the


DataFrames given above:
1.To add DataFrames df1 and df2.
2.To add 10 values into df1 DataFrame
3.To add 5 values into mark1 columns of DataFrame
4.To add DataFrame d1 into d2

Note : Solve and write Practical assignment -2 based on the topic DataFrame in the IP practical file.

Holiday Homework-2
CLASS XII – IP
TOPIC: Series and DataFrame

1. Write a program to create a series to print scalar value “5” four times.
2 Write a program to create a series object F1 using a dictionary that stores the number of
furniture in each lab of your school.

Note: Assume four furniture names are Table, Sofa, Chair and stool having 40, 2,45,26 items
respectively and pandas library has been imported as pd.

3. Write a program to create a series object using a dictionary that stores the number of
students in each house of CLASS 12D of your school.
Note: Assume four house names are Beas, Chenab, Ravi and Satluj having 18, 2, 20, 18 students
respectively and pandas library has been imported as pd.

4. Write the output of the given command:


import pandas as pd
s=pd.Series([1,2,3,4,5,6],index=['A','B','C','D','E','F'])
print(s[s%2==0])
5. Consider the following series named animal

Write the output of the command: print(animal[::-3])

6. Give the output:


import pandas as pd
name=[‘Raj’,’Ankur’,’Harsh’]
p=pd.Series(name,index=[2,5,6])
print(p)
p1=p.reindex([2,5])
print (p1)

7. How many elements will be there in the series named “S1”?


>>> S1 = pd.Series(range(5,10))
>>> print(S1)

8. Consider the given DataFrame ‘Stock’:


Name Price
0 Nancy Drew 150
1 Hardy boys 180
2 Diary of a wimpy kid 225
3 Harry Potter 500
Write suitable Python statements for the following:
i. Add a column called Special_Price with the following
data: [135,150,200,440].
ii. Add a new book named ‘The Secret' having price 800.
iii. Remove the column Price.
iv.Remove first and third rows from DataFrame

9. Consider the following dataframe ndf as shown below:


(A) Write statements to do the following:
(a) Extract column col3
(b) Extract row t3
(c) Extract row t2’s column col2’s value
(d) Extract row t4’s columns col2, col3, and Res
(e) Delete rows t2 and t3
(f) Delete columns col2 and Res
(B) What will be the output produced by the following statements?
(a) print(df.at[‘t3’, ‘Res’], df.at[‘t1’, ‘col3’])
(b) print(df.iat[3,2], df.iat[2,3])
(c) print(df.loc[‘t2’ : , : ])
(d) print(df.loc[ : , ‘col3’ : ] )
(e) print(print(df.loc[‘t2’ : ‘t3’, ‘col3’ : ] )
(f) print(df.iloc[ :2, 2:] )
(g) print(df.iloc[2: , :3] )
(h) print(df.iloc[1:3, 2:3])
10. What will be the output of the following code:
import pandas as pd
d = {‘one’ : pd.Series([1., 2., 3.], index = [‘a’, ‘b’, ‘c’]),
‘two’ : pd.Series([1., 2., 3., 4.], index = [‘a’, ‘b’ , ‘c’, ‘d’ ]) }
df . pd.DataFrame(d)
df1 = pd.DataFrame(d, index = [‘d’, ‘b’, ‘a’])
df2= pd.DataFrame(d, index = [‘d’, ‘a’], columns = [‘two’, ‘three’])
print(df)
print(df1)

Note: Solve in the notebook .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy