Wa0004
Wa0004
import Pandas as pd
D1 = {'Name': 'Rakshit', 'Age': 25}
D2 = {'Name': 'Paul', 'Age': 30}
D3 = {'Name': 'Ayesha", 'Age': 28}
data = [D1,D2,D3)
df = pd.Dataframe(data) print(df)
Ans:-
import pandas as pd
D1 = {'Name': 'Rakshit', 'Age': 25}
D2 = {'Name': 'Paul', 'Age': 30}
D3 = {'Name': 'Ayesha', 'Age': 28} data = [D1, D2, D3]
df = pd.DataFrame(data) print(df)
Changes Made :
i. Changed Pandas to pandas.
ii. Corrected mismatched string quotation marks
iii. Corrected the closing parenthesis in the list data.
iv. Changed Dataframe to DataFrame.
(1/2 mark for each correct correction and underlining)
OR
B) Complete the given Python code to get the required output (ignore
the dtype attribute) as
Output:
Tamil Nadu Chennai
Uttar Pradesh Lucknow
Manipur Imphal
Code:
import as pd
data = ['Chennai',' ','Imphal']
indx = ['Tamil Nadu','Uttar Pradesh','Manipur']
s = pd.Series( , index)
print( )
Ans :- import pandas as pd
data = ['Chennai', 'Lucknow', 'Imphal']
indx = ['Tamil Nadu','Uttar Pradesh’, ‘Manipur']
s = pd.Series(data, indx)
print(s)
(1/2 mark for each correct fill in the blank)
C) Write a Python program to create the following DataFrame using
a list of dictionaries.
Product Price
0 Laptop 60000
1 Desktop 45000
2 Monitor 15000
3 Tablet 30000
OR
B) Write a Python Program to create a Pandas Series as shown below
using a dictionary. Note that the left column indicates the indices
and the right column displays the data.
Russia Mosco
Hungary Budpest
Switzerland Burn
Pre-Board2 -IP
To display last five rows of a series object ‘S’,
you may write:
i. S.Head()
ii. S.Tail(5)
iii. S.Head(5)
iv. S.tail()
Which of the following statement will import pandas library?
i. Import pandas as pd
ii. import Pandas as py
iii. import pandas as pd
iv. import panda as pd
Which of the following can be used to specify the data while creating a
DataFrame?
i. Series
ii. List of Dictionaries
iii. Structured ndarray
iv. All of these
Write a program to create a series object using a dictionary that stores the number of students
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.
Write a Python code to create a Data Frame with appropriate column headings from
the list given below:
[[101,'Gurman',98],[102,'Rajveer',95],[103,'Samar' ,96],[104,'Yuvraj',88]]
Name Price
1. Nancy Drew 150
2. Hardy boys 180
3. Diary of a wimpy kid 225
4. Harry Potter 500