Path: blob/main/quiz/quiz3.ipynb
3223 views
Q1
Consider the two DataFrames shown below, both of which have Name as the index. Which of the following expressions can be used to get the data of all students (from student_df) including their roles as staff, where nan denotes no role? MergingDataFrame_ed 
Q2
Consider a DataFrame named df with columns named P2010, P2011, P2012, P2013, P2014 and P2015 containing float values. We want to use the apply method to get a new DataFrame named result_df with a new column AVG. The AVG column should average the float values across P2010 to P2015. The apply method should also remove the 6 original columns (P2010 to P2015). For that, what should be the value of x and y in the given code? PandasIdioms_ed
Q3
Consider the Dataframe df below, instatiated with a list of grades, ordered from best grade to worst. Which of the following options can be used to substitute X in the code given below, if we want to get all the grades between 'A' and 'B' where 'A' is better than 'B'? Scales
Q4
Consider the DataFrame df shown in the image below. Which of the following can return the head of the pivot table as shown in the image below df? PivotTable_ed 
Q5
Assume that the date '11/29/2019' in MM/DD/YYYY format is the 4th day of the week, what will be the result of the following? DateFunctionality_ed
Q6
Consider a DataFrame df. We want to create groups based on the column group_key in the DataFrame and fill the nan values with group means using:
filling_mean = lambda g: g.fillna(g.mean())
Which of the following is correct for performing this task? GroupBy_ed
Q7
Consider the DataFrames above, both of which have a standard integer based index. Which of the following can be used to get the data of all students (from student_df) and merge it with their staff roles where nan denotes no role? MergingDataFrame_ed
Q8
Consider a DataFrame df with columns name, reviews_per_month, and review_scores_value. This DataFrame also consists of several missing values. Which of the following can be used to: i) calculate the number of entries in the name column, and ii) calculate the mean and standard deviation of the reviews_per_month, grouping by different review_scores_value? GroupBy_ed
Q9
What will be the result of the following code?: DateFunctionality_ed
Q10
Which of the following is not a valid expression to create a Pandas GroupBy object from the DataFrame shown below? GroupBy_ed 
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-46-a901e4cdd01b> in <module>()
----> 1 df.groupby('vegetable')
c:\users\syy\appdata\local\programs\python\python36-32\lib\site-packages\pandas\core\frame.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, dropna)
6523 squeeze=squeeze,
6524 observed=observed,
-> 6525 dropna=dropna,
6526 )
6527
c:\users\syy\appdata\local\programs\python\python36-32\lib\site-packages\pandas\core\groupby\groupby.py in __init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, observed, mutated, dropna)
531 observed=observed,
532 mutated=self.mutated,
--> 533 dropna=self.dropna,
534 )
535
c:\users\syy\appdata\local\programs\python\python36-32\lib\site-packages\pandas\core\groupby\grouper.py in get_grouper(obj, key, axis, level, sort, observed, mutated, validate, dropna)
784 in_axis, name, level, gpr = False, None, gpr, None
785 else:
--> 786 raise KeyError(gpr)
787 elif isinstance(gpr, Grouper) and gpr.key is not None:
788 # Add key to exclusions
KeyError: 'vegetable'