Sorry For Inconvenience, Site is Under Maintenance. Please Goto HomePage

Python Pandas Fresco Play MCQs Answers

Notes Bureau

Python Pandas Fresco Play MCQs Answers(0.6 Credits)


Disclaimer: The main motive to provide this solution is to help and support those who are unable to do these courses due to facing some issue and having a little bit lack of knowledge. All of the material and information contained on this website is for knowledge and education purposes only.


Try to understand these solutions and solve your Hands-On problems. (Not encourage copy and paste these solutions)

Python Pandas Fresco Play MCQs Answers


Course Path: Data Science/DATA SCIENTIST'S TOOLBOX/Python Pandas

All Question of the Quiz Present Below for Ease Use Ctrl + F to find the Question.

Suggestion: If you didn't find the question, Search by options to get a more accurate result.


Quiz on Pandas Data Structures


1.What is the data type of series s defined in below code?

import pandas as pd

s = pd.Series([9.2, 'hello', 89])

  1. object
  2. str
  3. float
  4. int

Answer: 1)object

2.What is the shape of the data frame df defined in the below-shown code?

import pandas as pd

data = [{'a': 1, 'b': 2}, {'a': 5, 'b': 10, 'c': 20}]

df = pd.DataFrame(data, columns=['a', 'b'])

  1. (3,)
  2. (2,2)
  3. Data Frame df is not created
  4. (2,3)

Answer: 2)(2,2)

3.What is the output of the expression 'b' in s, where s is the series defined as shown below?

s = pd.Series([89.2, 76.4, 98.2, 75.9], index=list('abcd'))

  1. Error
  2. True
  3. False
  4. None of the options

Answer: 2)True

4.Which of the following argument is used to label the elements of a series?

  1. labels
  2. values
  3. elements
  4. index

Answer: 4)index

5.Which of the following expressions are used to check if each element of a series s is present in the list of elements [67, 32]. Series s is defined as shown below.

s = pd.Series([99, 32, 67],list('abc'))

  1. [67, 32] isin s
  2. s in [67, 32]
  3. [67, 32] in s
  4. s.isin([67, 32])

Answer: 4)s.isin([67, 32])

6.Which of the following cannot be used to create a Data frame?

  1. A dictionary of tuples
  2. A tuple of tuples
  3. A dictionary of lists
  4. A list of lists

Answer: 2)A tuple of tuples

7.Which of the following is not a Data Structure of Pandas?

  1. Data Frame
  2. Series
  3. Dictionary
  4. Panel

Answer: 3)Dictionary

8.What is the output of the following code?

import pandas as pd

s = pd.Series([89.2, 76.4, 98.2, 75.9], index=list('abcd'))

print(s[['c', 'a']])

  1. a    89.2
    c    98.2
    dtype: float64
  2. c    98.2
    a    89.2
    dtype: float64
  3. c 98.2, a 89.2
  4. a 89.2, c 98.2

Answer: 2)c    98.2
a    89.2
dtype: float64

9.What is the shape of the data frame df defined in the below-shown code?

import pandas as pd

data = [{'a': 1, 'b': 2}, {'a': 5, 'b': 10, 'c': 20}]

df = pd.DataFrame(data)

  1. (2,3)
  2. Data Frame df is not created
  3. (2,2)
  4. (3,)

Answer: 1)(2,3)

10.Which of the following attributes or arguments are used to set column names of a data frame?

  1. columns
  2. column
  3. index
  4. indexes

Answer: 1)columns

Quiz on Accessing Data Elements


1.Which of the following expression returns last two rows of df, defined below?

import pandas as pd

df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

  1. df.iloc[:'r3']
  2. df.loc['r2':'r3']
  3. df.iloc['r2':'r3']
  4. df.loc[:'r3']

Answer: 2)df.loc['r2':'r3']

2.Which of the following expression returns the first two rows of df, defined below?

import pandas as pd

df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

  1. df.iloc[:2]
  2. Both df[:2] and df.iloc[:2]
  3. df[:2]
  4. None of the options

Answer: 2)Both df[:2] and df.iloc[:2]

3.What does the expression df.loc['r4'] = [67, 78] do for the data frame df, defined below?

df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

  1. Over writes the last row
  2. Adds a new row
  3. Adds a column
  4. Results in Error

Answer: 2)Adds a new row

4.Which of the following expression is used to add a new column 'C' to a data frame df, with three rows?

  1. df.ix['C'] = [12, 98, 45]
  2. df.loc['C'] = [12, 98, 45]
  3. df['C'] = [12, 98, 45]
  4. df.iloc['C'] = [12, 98, 45]

Answer: 3)df['C'] = [12, 98, 45]

5.Which of the following expression returns the second row of df, defined below?

import pandas

df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

  1. df.loc[1]
  2. df[1]
  3. df.iloc['r2']
  4. df.iloc[1]

Answer: 4)df.iloc[1]

6.Which of the following expression is used to delete the column, A from a data frame named df?

  1. remove df['A']
  2. rm df['A']
  3. del df['A']
  4. delete df['A']

Answer: 3)del df['A']

7.Which of the following expression returns data of column B of data frame df, defined below?

import pandas as pd

df = pd.DataFrame({'A':[34, 78, 54], 'B':[12, 67, 43]}, index=['r1', 'r2', 'r3'])

  1. None of the options
  2. df.B
  3. df['A']
  4. df[1]

Answer: 2)df.B


Quiz on I/O in pandas


1.State whether the following statement is true or false? The read_csv method can read multiple columns of an input file as indexes.

  1. False
  2. True

Answer: 2)True

2.Which of the following method is used to read data from excel files?

  1. read_excel
  2. excel_read
  3. excel_reader
  4. read

Answer: 1)read_excel

3.Which of the following is used as argument of read_csv method to treat data of specific columns as dates?

  1. date_parse
  2. date_col
  3. parse_dates
  4. dates

Answer: 3)parse_dates

4.State whether the following statement is true or false? The read_csv method, by default, reads all blank lines of an input CSV file.

  1. False
  2. True

Answer: 1)False

5.Which of the following is used as an argument of read_csv method to skip first n lines of an input CSV file?

  1. skip
  2. skipn
  3. skipnrows
  4. skiprows

Answer: 4)skiprows

6.________ is used as an argument of the readcsv method to make data of a specific column as an index.

  1. index
  2. id
  3. id_col
  4. index_col

Answer: 4)index_col

7.Which of the following method is used to write a data frame data to an output CSV file?

  1. csv_write
  2. write_csv
  3. to_csv
  4. csv_writer

Answer: 3)to_csv


Quiz on Indexing


1.What is the length of DatetimeIndex object created with the below expression?

pd.date_range('11-Sep-2017', '17-Sep-2017', freq='2D')

  1. 4
  2. 6
  3. 3
  4. 7

Answer: 1)4

2.What is the output of the following code?

import pandas as pd

d = pd.date_range('11-Sep-2017', '17-Sep-2017', freq='2D')

len(d[d.isin(pd.to_datetime(['12-09-2017', '15-09-2017']))])

  1. 2
  2. 4
  3. 1
  4. 0

Answer: 3)1

3.What does the expression d + pd.Timedelta('1 days 2 hours') do to DatetimeIndex object d, defined below?

d = pd.date_range('11-Sep-2017', '17-Sep-2017', freq='2D')

  1. Increases each datetime value by 1 day and 2 hours
  2. Results in Error
  3. Increases each datetime value by 1 day
  4. No changes to each datetime value

Answer: 1)Increases each datetime value by 1 day and 2 hours

4.Which of the following method is used to convert a list of dates like strings into datetime objects?

  1. datetime
  2. date
  3. to_datetime
  4. to_date

Answer: 3)to_datetime

5.What is the length of PeriodIndex object created from the expression pd.period_range('11-Sep-2017', '17-Sep-2017', freq='M')?

  1. 1
  2. 0
  3. 6
  4. 3

Answer: 1)1

6.What is the length of DatetimeIndex object created with the below expression?

pd.bdate_range('11-Sep-2017', '17-Sep-2017', freq='2D')

  1. 4
  2. 7
  3. 3
  4. 6

Answer: 1)4


Quiz on Data Cleaning


1.By default, missing values in any data set are read as ...........

  1. NA
  2. NaN
  3. .
  4. 0

Answer: 2)NaN

2.Which of the following method is used to fill null values with a deafult value?

  1. fill
  2. keepna
  3. fillna
  4. keep

Answer: 3)fillna

3.Which of the following method of pandas is used to check if each value is a null or not?

  1. NULL
  2. isnan
  3. isnull
  4. ifnull

Answer: 3)isnull

4.Which of the following methods is used to remove duplicates?

  1. remove_dup
  2. remove
  3. drop_dup
  4. drop_duplicates

Answer: 4)drop_duplicates

5.Which of the following argument values are allowed for the method argument of fillna?

  1. pad
  2. bfill
  3. All
  4. backfill
  5. ffill

Answer: 3)All

6.Which of the following method is used to eliminate rows with null values?

  1. dropna
  2. drop
  3. remove
  4. removena

Answer: 1)dropna

7.Unrecognized datetime value is treated as _________.

  1. NaV
  2. NaD
  3. NaT
  4. NaN

Answer: 3)NaT


Quiz on Data Aggregation


1.Which of the following methods is used to group data of a data frame, based on specific columns?

  1. groupby
  2. aggregate
  3. group
  4. groupat

Answer: 1)groupby

2.What does the expression df.iloc[:, lambda x : [0,3]] do? Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3'].

  1. Selects Column 'A' and 'C'
  2. Results in Error
  3. Selects Columns 'A', 'B', and 'C'
  4. Selects Column 'A' and 'D'

Answer: 4)Selects Column 'A' and 'D'

3.Consider a data frame df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4', 'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. What does the expression g = df.groupby(df.index.str.len()) do?

  1. Groups df based on index values
  2. Groups df based on length of each index value
  3. Groups df based on index strings
  4. Data frames cannot be grouped by index values. Hence it results in Error.

Answer: 4)Data frames cannot be grouped by index values. Hence it results in Error.

4.Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3'], Which of the following expression is used to extract columns 'C' and 'D'?

  1. df.loc[:, lambda x : x.columns.isin(['C', 'D'])]
  2. df[:, lambda x : x.columns.isin(['C', 'D'])]
  3. lambda x : x.columns.isin(['C', 'D'])
  4. None

Answer: 1)df.loc[:, lambda x : x.columns.isin(['C', 'D'])]

5.Which of the following method can be applied on a groupby object to get the group details?

  1. group_details
  2. groups
  3. get_groups
  4. fetch_groups

Answer: 2)groups

6.Consider a data frame df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4', 'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. How many rows are obtained after executing the below expressions

 g = df.groupby(df.index.str.len())

g.filter(lambda x: len(x) > 1)

  1. 9
  2. 1
  3. 5
  4. 10

Answer: 1)9

7.Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3']. What does the expression df[lambda x : x.index.str.endswith('3')] do?

  1. Returns the row name r3
  2. Results in Error
  3. Returns the third column
  4. Filters the row labelled r3

Answer: 4)Filters the row labelled r3

8.Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3']. Which of the following expression filters the rows whose column B values are greater than 45 and column 'C' values are less than 30?

  1. df.loc[(df.B > 45) & (df.C < 30)]
  2. df[df.B > 45 & df.C < 30]
  3. df.loc[df.B > 45 & df.C < 30]
  4. (df.B > 45) & (df.C < 30)

Answer: 1)df.loc[(df.B > 45) & (df.C < 30)]

9.Consider a data frame df with columns ['A', 'B', 'C', 'D'] and rows ['r1', 'r2', 'r3']. Which of the following expression filters the rows whose column B values are greater than 45?

  1. df.iloc[df.B > 45]
  2. df.B > 45
  3. df[df.B > 45]
  4. df.loc[B > 45]

Answer: 3)df[df.B > 45]

10.Consider a data frame df with 10 rows and index [ 'r1', 'r2', 'r3', 'row4', 'row5', 'row6', 'r7', 'r8', 'r9', 'row10']. What does the aggregate method shown in below code do?

 g = df.groupby(df.index.str.len())

g.aggregate({'A':len, 'B':np.sum})

  1. Computes Sum of column A values
  2. Computes length of column A
  3. Computes length of column A and Sum of Column B values of each group
  4. Computes length of column A and Sum of Column B values

Answer: 3)Computes length of column A and Sum of Column B values of each group


Quiz on Data Merging


1.Which of the following argument is used to ignore the index while concatenating two data frames?

  1. index
  2. no_index
  3. ignore_index
  4. ignore

Answer: 3)ignore_index

2.Which of the following method is used to concatenate two or more data frames?

  1. con
  2. concatenate
  3. concat
  4. .

Answer: 3)concat

3.What is the shape of d defined in below code?

import pandas as pd

s1 = pd.Series([0, 1, 2, 3])

s2 = pd.Series([0, 1, 2, 3])

s3 = pd.Series([0, 1, 4, 5])

d = pd.concat([s1, s2, s3], axis=1)

  1. (4,4)
  2. (4,3)
  3. (3,4)
  4. (3,3)

Answer: 2)(4,3)

4.Which of the following argument is used to set the key to be used for merging two data frames?

  1. key
  2. on
  3. k
  4. keyon

Answer: 2)on

5.Which argument is used to override the existing column names, while using concat method?

  1. columns
  2. override
  3. new
  4. keys

Answer: 4)keys

6.Which of the following are allowed values of the argument how of merge method?

  1. inner
  2. right
  3. All the options
  4. outer
  5. left

Answer: 3)All the options


Final Assessment

Questions in the final assessment are from the above questions only. To find questions easily use Ctrl + F to search.

Post a Comment

Any comments and suggestion will be appreciated.
Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.

Join Telegram Channel

Join Notes Bureau Lets Teach and Learn

Join Telegram Channel
CLOSE ADS
CLOSE ADS