Skip to content

Commit

Permalink
sp24 final q3 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pallavisprabhu authored and pallavisprabhu committed Dec 5, 2024
1 parent d94bd5b commit 903522d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 11 deletions.
59 changes: 53 additions & 6 deletions docs/sp24-final/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h1 class="title">Spring 2024 Final Exam</h1>
<li><code>"Bed"</code> (<code>str</code>): The number of bedrooms in the
apartment. Values are <code>"Studio"</code>, <code>"One"</code>,
<code>"Two"</code>, and <code>"Three"</code>.</li>
<li><code>"Bath"</code> (<code>int</code>): The number of bathrooms in
<li><code>"Bath"</code> (<code>str</code>): The number of bathrooms in
the apartment. Values are <code>"One"</code>,
<code>"One and a half"</code>, <code>"Two"</code>,
<code>"Two and a half"</code>, and <code>"Three"</code>.</li>
Expand Down Expand Up @@ -705,13 +705,13 @@ <h3 id="problem-3.2">Problem 3.2</h3>
that apply.</p>
<ul class="task-list">
<li><p><input type="checkbox" disabled="" /> No complexes have studio apartments.</p></li>
<li><p><input type="checkbox" disabled="" /> Every complex has exactly one studio apartment.</p></li>
<li><p><input type="checkbox" disabled="" /> Every complex has at least one studio apartment.</p></li>
<li><p><input type="checkbox" disabled="" /> Every complex has exactly one studio apartment.</p></li>
<li><p><input type="checkbox" disabled="" /> Some complexes have only studio apartments.</p></li>
<li><p><input type="checkbox" disabled="" /> In every complex, the single cheapest apartment is a studio
apartment.</p></li>
<li><p><input type="checkbox" disabled="" /> In every complex, the average price of a studio apartment is less
than or equal to the average price of a one bedroom apartment.</p></li>
<li><p><input type="checkbox" disabled="" /> In every complex, the single cheapest apartment is a studio
apartment.</p></li>
<li><p><input type="checkbox" disabled="" /> None of these.</p></li>
</ul>
<div id="accordionExample" class="accordion">
Expand All @@ -727,7 +727,54 @@ <h2 class="accordion-header" id="heading3_2">
<header id="title-block-header">
<h1 class="title"> </h1>
</header>
<p><strong>Answer:</strong> Options 3 and 6.</p>
<p><strong>Answer:</strong> Options 2 and 5</p>
<p><code>alternate approach</code> first groups by <code>"Bed"</code>
and <code>"Complex"</code> , takes the mean of all the columns, and
resets the index such that <code>"Bed"</code> and <code>"Complex"</code>
are no longer indexes. Now there is one row per <code>"Bed"</code> and
<code>"Complex"</code> combination that exists in <code>apts</code> and
all columns contain the mean value for each of these <code>"Bed"</code>
and <code>"Complex"</code> combinations. Then it groups by
<code>"Complex"</code> again, taking the minimum value of all columns.
The output is a DataFrame indexed by <code>"Complex"</code> where the
<code>"Rent"</code>column contains the minimum rent (from of all the
average prices for each type of <code>"Bed"</code>).</p>
<ul>
<li>Option 1 is incorrect. This is not necessarily true. The
<code>"Rent"</code> column in <code>alternate_approach</code>in contains
the minimum of all the average prices for each type of
<code>"Bed"</code> and the <code>"Rent"</code> column in
<code>"studio_avg"</code> contains the average rent for studios in each
type of complex. Even though they contain the same values, this does not
mean that no studios exist in any complexes. If this were the case,
<code>studio_avg</code> would be an empty DataFrame and
<code>alternate_approach</code> would not be.</li>
<li>Option 2 is correct. If these columns are the same, that means that
for each complex, there must at least one studio apartment. If this was
not the case and there were complexes with no studio apartments,
complexes that may appear in <code>alternate_approach</code> would not
appear in <code>studio_avg</code>.</li>
<li>Option 3 is incorrect. This is not necessarily true. Complexes can
have more than one studio. <code>studio_avg</code> has the average of
all these studios for each complex and <code>alternate_approach</code>
will have the minimum rent (from all the average prices for each type of
bedroom). Just because the columns are the same does not mean that there
is only one studio per complex.</li>
<li>Option 4 is incorrect. This is not necessarily true. Just because
the columns are the same does not mean that complexes only have studios.
Perhaps studios just have the minimum rent on average across all
complexes as explored in Option 5 below.</li>
<li>Option 5 is correct. <code>studio_avg</code> contains the average
price for a studio in each complex. <code>alternate_approach</code>
contains the minimum rent from the average rents of all types of
bedrooms for each complex. Since these columns are the same, this means
that the average price of a studio must be lower (or equal to) the
average price of a one bedroom (or any other type of bedroom) for all
the rent values in <code>alternate_approach</code> to align with all the
values in <code>studio_avg</code>.</li>
<li>Option 6 is incorrect. As shown above, there are correct answers to
this question.</li>
</ul>
<hr/>
<h5>Difficulty: ⭐️⭐️⭐️</h5>
<p>
Expand Down Expand Up @@ -2669,7 +2716,7 @@ <h1 class="title"> </h1>
bedrooms}}{\# \text{ of rows in bedrooms}} \to \dfrac{\text{sum of
``Rent" in no}\_\text{studio}}{\# \text{ of rows in bedrooms}} \to
\dfrac{\text{sum of ``Rent" in no}\_\text{studio}}{\text{sum of
"Bed" in apts}}</span></p>
``Bed" in apts}}</span></p>
<p><br/></p>
<p>Option 3 is incorrect. The first part of Option 3,
<code>no_studio.get("Rent") / no_studio.get("Bed")</code>, produces a
Expand Down
2 changes: 1 addition & 1 deletion problems/sp24-final/data-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The columns of `apts` are as follows:

- `"Rent"` (`int`): The monthly rent for the apartment, in dollars.
- `"Bed"` (`str`): The number of bedrooms in the apartment. Values are `"Studio"`, `"One"`, `"Two"`, and `"Three"`.
- `"Bath"` (`int`): The number of bathrooms in the apartment. Values are `"One"`, `"One and a half"`, `"Two"`, `"Two and a half"`, and `"Three"`.
- `"Bath"` (`str`): The number of bathrooms in the apartment. Values are `"One"`, `"One and a half"`, `"Two"`, `"Two and a half"`, and `"Three"`.
- `"Laundry"` (`bool`): If the apartment comes with an in-unit washer and dryer.
- `"Sqft"` (`int`): The area of the apartment, in square feet.
- `"Neighborhood"` (`str`): The neighborhood in which the apartment is located.
Expand Down
15 changes: 12 additions & 3 deletions problems/sp24-final/q03.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,24 @@ alternate_approach = grouped.groupby("Complex").min()
Suppose that the `"Rent"` column of `alternate_approach` has all the same values as the `"Rent"` column of `studio_avg`, where `studio_avg` is the DataFrame described in part \(a\). Which of the following are valid conclusions about `apts`? Select all that apply.

[ ] No complexes have studio apartments.
[ ] Every complex has exactly one studio apartment.
[ ] Every complex has at least one studio apartment.
[ ] Every complex has exactly one studio apartment.
[ ] Some complexes have only studio apartments.
[ ] In every complex, the single cheapest apartment is a studio apartment.
[ ] In every complex, the average price of a studio apartment is less than or equal to the average price of a one bedroom apartment.
[ ] In every complex, the single cheapest apartment is a studio apartment.
[ ] None of these.

# BEGIN SOLUTION
**Answer:** Options 3 and 6.
**Answer:** Options 2 and 5

`alternate approach` first groups by `"Bed"` and `"Complex"` , takes the mean of all the columns, and resets the index such that `"Bed"` and `"Complex"` are no longer indexes. Now there is one row per `"Bed"` and `"Complex"` combination that exists in `apts` and all columns contain the mean value for each of these `"Bed"` and `"Complex"` combinations. Then it groups by `"Complex"` again, taking the minimum value of all columns. The output is a DataFrame indexed by `"Complex"` where the `"Rent"`column contains the minimum rent (from of all the average prices for each type of `"Bed"`).

- Option 1 is incorrect. This is not necessarily true. The `"Rent"` column in `alternate_approach`in contains the minimum of all the average prices for each type of `"Bed"` and the `"Rent"` column in `"studio_avg"` contains the average rent for studios in each type of complex. Even though they contain the same values, this does not mean that no studios exist in any complexes. If this were the case, `studio_avg` would be an empty DataFrame and `alternate_approach` would not be.
- Option 2 is correct. If these columns are the same, that means that for each complex, there must at least one studio apartment. If this was not the case and there were complexes with no studio apartments, complexes that may appear in `alternate_approach` would not appear in `studio_avg`.
- Option 3 is incorrect. This is not necessarily true. Complexes can have more than one studio. `studio_avg` has the average of all these studios for each complex and `alternate_approach` will have the minimum rent (from all the average prices for each type of bedroom). Just because the columns are the same does not mean that there is only one studio per complex.
- Option 4 is incorrect. This is not necessarily true. Just because the columns are the same does not mean that complexes only have studios. Perhaps studios just have the minimum rent on average across all complexes as explored in Option 5 below.
- Option 5 is correct. `studio_avg` contains the average price for a studio in each complex. `alternate_approach` contains the minimum rent from the average rents of all types of bedrooms for each complex. Since these columns are the same, this means that the average price of a studio must be lower (or equal to) the average price of a one bedroom (or any other type of bedroom) for all the rent values in `alternate_approach` to align with all the values in `studio_avg`.
- Option 6 is incorrect. As shown above, there are correct answers to this question.

<average>73</average>

Expand Down
2 changes: 1 addition & 1 deletion problems/sp24-final/q15.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Option 2 is correct. We can view the bedroom code as the same as summing all of

<br>

$$\dfrac{\text{sum of ``Cost" in bedrooms}}{\# \text{ of rows in bedrooms}} \to \dfrac{\text{sum of ``Rent" in no}\_\text{studio}}{\# \text{ of rows in bedrooms}} \to \dfrac{\text{sum of ``Rent" in no}\_\text{studio}}{\text{sum of "Bed" in apts}}$$
$$\dfrac{\text{sum of ``Cost" in bedrooms}}{\# \text{ of rows in bedrooms}} \to \dfrac{\text{sum of ``Rent" in no}\_\text{studio}}{\# \text{ of rows in bedrooms}} \to \dfrac{\text{sum of ``Rent" in no}\_\text{studio}}{\text{sum of ``Bed" in apts}}$$

<br>

Expand Down

0 comments on commit 903522d

Please sign in to comment.