Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions class_materials/Intro2Pandas/2020/q2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
" Returns\n",
" -------\n",
" popular_df: pandas.DataFrame\n",
" The dataframe containing the top 3 most popular effective drugs\n",
" The dataframe containing the top 3 most popular effective drugs.\n",
" This dataframe should be dimenion (3 x #).\n",
" \n",
" \"\"\"\n",
" # Processing code here\n",
Expand All @@ -112,7 +113,7 @@
"source": [
"def get_most_effective_drugs(nonzero_df):\n",
" \"\"\"\n",
" Get the top 2 most effective and commonly used drugs\n",
" Get the top 2 most effective among the 3 most commonly used drugs\n",
" \n",
" Input\n",
" -----\n",
Expand Down Expand Up @@ -212,7 +213,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.8"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
5 changes: 3 additions & 2 deletions class_materials/Intro2Pandas/2020/q2.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def get_most_popular_drugs(nonzero_df):
Returns
-------
popular_df: pandas.DataFrame
The dataframe containing the top 3 most popular effective drugs
The dataframe containing the top 3 most popular effective drugs.
This dataframe should be dimenion (3 x #).

"""
# Processing code here
Expand All @@ -72,7 +73,7 @@ def get_most_popular_drugs(nonzero_df):

def get_most_effective_drugs(nonzero_df):
"""
Get the top 2 most effective and commonly used drugs
Get the top 2 most effective among the 3 most commonly used drugs

Input
-----
Expand Down
7 changes: 4 additions & 3 deletions class_materials/Intro2Pandas/2020/q2_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def filter_patients(df):
The dataframe after filtering

"""
nonzero_df = df[(df["Effect"] >= 0) & (df["Year"] > 2015)]
nonzero_df = df[(df["Effect"] > 0) & (df["Year"] > 2015)]
return nonzero_df


Expand All @@ -62,7 +62,8 @@ def get_most_popular_drugs(nonzero_df):
Returns
-------
popular_df: pandas.DataFrame
The dataframe containing the top 3 most popular effective drugs
The dataframe containing the top 3 most popular effective drugs.
This dataframe should be dimenion (3 x #).

"""
drug_counts = nonzero_df.groupby(["Drug"]).count()
Expand All @@ -72,7 +73,7 @@ def get_most_popular_drugs(nonzero_df):

def get_most_effective_drugs(nonzero_df):
"""
Get the top 2 most effective and commonly used drugs
Get the top 2 most effective among the 3 most commonly used drugs

Input
-----
Expand Down