[go: up one dir, main page]

0% found this document useful (0 votes)
32 views7 pages

pandasquiz

The document contains a series of quiz questions and answers related to a dataset of houses, including inquiries about zip codes, house grades, null values, and various data manipulation techniques using pandas. Key answers include the costliest house zip code (98102), the number of grade 10 houses (1134), and the absence of null values (0). The document also covers data operations such as filtering, joining dataframes, and calculating statistics.

Uploaded by

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

pandasquiz

The document contains a series of quiz questions and answers related to a dataset of houses, including inquiries about zip codes, house grades, null values, and various data manipulation techniques using pandas. Key answers include the costliest house zip code (98102), the number of grade 10 houses (1134), and the absence of null values (0). The document also covers data operations such as filtering, joining dataframes, and calculating statistics.

Uploaded by

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

Which zip code has the costliest house?

Marked Answer :
98102
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

How many houses are having grade 10?

Marked Answer :
1134
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

How many null values are there in the dataset?

Marked Answer :
0
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Does this 9126100861 customer have a waterfront?

Marked Answer :
No
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

How many houses have 3 views?

Marked Answer :
510
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================
What is the lowest price of the house?

Marked Answer :
75000
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Which area has the biggest sqft_living?

Marked Answer :
98053
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Which of the following is having a one-dimensional array?

Marked Answer :
Series data type
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

What value will you get on the left side after printing a series format data?

Marked Answer :
Index
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

In what format the keys will get converted into when we convert the dictionary data
into
data frame format?

Marked Answer :
Column
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Write a function to perform the following operation:


Increase the grade of the house by 1 if the sqft of the house is greater than 0 and
less than
equal to 400. If the total sqft of the house is greater than 400, increase the
grade of the house
by 2.
After creating the above function, which syntax will be using when using apply
function to run
the above created function in the dataset?

Marked Answer :
data.apply(your_function_name(arg1))
Total Marks :1MARKS OBTAINED0

===================================================================================
============================
===================================================================================
============================

How to check the duplicate values on id,grade and location?

Marked Answer :
Both A & C
Total Marks :1MARKS OBTAINED0

===================================================================================
============================
===================================================================================
============================

Which of the following syntax will display the last two records of df?
import pandas as pd
df = pd.DataFrame({‘A’:[34, 78, 54], ‘B’:[12, 67, 43]}, index=[‘r1’, ‘r2’, ‘r3’])

Marked Answer :
df.loc[‘r2′:’r3’]
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Which of the following is/are true about loc in pandas:

Marked Answer :
All of the above
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Which of the following is the correct syntax for getting the houses where no. of
bedrooms is maximum having 3 views along with 1 waterfront?

Marked Answer :
housing[(housing[“bedrooms”]==housing[“bedrooms”].max()) & (housing[“view”]==3) &
(housing[“waterfront”]==1)]
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Create a separate data frame that satisfies the conditions below.


1. Houses built before 1980
2. Have more than 2 bedrooms
3. Have more than 2 floors.

Marked Answer :
data.loc[(data[“yr_built”] < 1980) & (data['floors'] > 2) & (data[‘bedrooms’] > 2)]

Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

For a given nested list, convert the same into a dataframe.

sample_list = [[‘Carl’, 22],

[‘Martha’, 25],

[‘Calvin’, 12],

[‘Stuart’, 15]

The resulting dataframe must contain the column names as ‘Name’, and ‘Age’ with the

respective values from the sample_list.

Marked Answer :
pd.DataFrame(sample_list, columns=[‘Name’, ‘Age’])
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================
For a given dictionary, convert the same into a dataframe.
sample_dict = {‘Cristiano’: [‘Ronaldo’,’Man U’, 801],
‘Lionel’: [‘Messi’,’PSG’, 758],
‘Luis’: [‘Suarez’,’Atletico Madrid’, 509],
‘Robert’: [‘Lewandowski’,’Bayern Munich’, 527],
‘Zlatan’: [‘Ibrahimovic’,’AC Milan’,553]
}

Marked Answer :
df1 = pd.DataFrame(sample_dict) df1 = df1.transpose() df1.reset_index(inplace =
True) df1.columns = [‘First Name’,’Last Name’, ‘Club’, ‘Goals’]
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

For a given tuple, convert the same into a dataframe.


sample_tuple = ([1, ‘one’, 3],
[2, ‘two’, 3],
[3, ‘Three’, 5],
[4, ‘Four’, 4],
[5, ‘Five’, 4])

Marked Answer :
pd.DataFrame(sample_tuple, columns=[‘Number’, ‘Number_text’, ‘txtlen’])
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Create a separate dataframe that contains houses ordered in ascending or descending


order of the prices of each house.

Marked Answer :
ascending = housing.sort_values(‘price’, ascending=True) descending =
housing.sort_values(‘price’, ascending=False)
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Calculate the mean and standard deviation of all the numerical values in the
dataset. For
example – the mean for the bedrooms column is 3.370 and the standard deviation is
0.930.

Marked Answer :
housing.describe()
Total Marks :1MARKS OBTAINED1
===================================================================================
============================
===================================================================================
============================

Create a new column with the floor area(sqft_living, sqft_lot, sqft_above,


sqft_basement, all
combined in one column).

Marked Answer :
data[‘Floor Area’] = data[‘sqft_living’], data[‘sqft_lot’], data[‘sqft_basement’],
data[‘sqft_above’]
Total Marks :1MARKS OBTAINED0

===================================================================================
============================
===================================================================================
============================

Perform the following operations on the dataframes given below.


A = pd.DataFrame([[‘Carl’, 22],[‘Martha’, 25],[‘Calvin’, 12],[‘Stuart’, 15]],
columns=[‘Name’, ‘Age’])
B = pd.DataFrame([[‘Melvin’, 25],[‘Martha’, 34],[‘Lewis’, 32],[‘Leo’, 25]],
columns=[‘Name’, ‘Age’])
1. Left Outer Join
2. Outer Join
3. Inner Join
4. Right Outer Join

Marked Answer :
inner = pd.merge(A, B, on=’Age’, how=’inner’) outer = pd.merge(A, B, on=’Age’,
how=’outer’) left_outer = pd.merge(A, B, on=’Age’, how=’left’) right_outer =
pd.merge(A, B, on=’Age’, how=’right’)
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

What will be the correlation between the columns sqft_living and sqft_above?

Marked Answer :
0.876597
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

If the correlation between the columns bathrooms and sqft_living is 0.754665, what
all
interpretations can be made about the two columns?
Marked Answer :
A positive correlation between the two columns
Total Marks :1MARKS OBTAINED1

===================================================================================
============================
===================================================================================
============================

Max marks : 25 Obtained marks : 22


Quiz is Submitted

You might also like