Skip to content
Open
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
83 changes: 83 additions & 0 deletions 21 Day Challenge/Day 1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Challenge: Modify the lease agreement with your signature without changing the original lease variable."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"lease = '''Dear Dot, \n",
" This document validates that you are beholden to a monthly payment of rent for this house.\n",
" Rent is to be paid by the first of every month.\n",
" Fill in your signature to agree to these terms. \n",
" -------------\n",
" Please Sign Here: \n",
"'''"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Dear Dot, \n",
"This document validates that you are beholden to a monthly payment of rent for this house.\n",
"Rent is to be paid by the first of every month.\n",
"Fill in your signature to agree to these terms.\n",
"-------------\n",
"Please Sign Here: Dot \n",
"\n"
]
}
],
"source": [
"# Solution\n",
"\n",
"signature = \"Dot\"\n",
"\n",
"new_lease = f'''\n",
"Dear Dot, \n",
"This document validates that you are beholden to a monthly payment of rent for this house.\n",
"Rent is to be paid by the first of every month.\n",
"Fill in your signature to agree to these terms.\n",
"-------------\n",
"Please Sign Here: {signature} \n",
"'''\n",
"print(new_lease)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
144 changes: 144 additions & 0 deletions 21 Day Challenge/Day 10.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Challenge\n",
"\n",
"Help Dot figure out how profitable selling fresh milk can be, by looking at the dataset for the cow farm. Fill in the values for the following columns based on the available data:\n",
"\n",
"Total Milk Production\n",
"Total Revenue\n",
"How much revenue did the cow farm make in the year 2020?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv('milk_32.csv')\n",
"df = df.drop(columns = ['Unnamed: 0'])\n",
" \n",
"df.head()\n",
"\n",
"#Month\tMonthly milk production: pounds per cow\tNumber of Cows\tTotal Milk Production\tPrice_Per_Pound\tTotal Revenue\n",
"#0\t07-Feb\t589.0\t30\tNaN\t0.22\tNaN\n",
"#1\t07-Mar\t561.0\t32\tNaN\t0.22\tNaN\n",
"#2\t07-Apr\t640.0\t35\tNaN\t0.22\tNaN\n",
"#3\t07-May\t656.0\t35\tNaN\t0.22\tNaN\n",
"#4\t07-Jun\t727.0\t35\tNaN\t0.22\tNaN"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Solution \n",
"df['Total Milk Production'] = df['Monthly milk production: pounds per cow'] * df['Number of Cows']\n",
"df.head()\n",
"\n",
"#Month\tMonthly milk production: pounds per cow\tNumber of Cows\tTotal Milk Production\tPrice_Per_Pound\tTotal Revenue\n",
"#0\t07-Feb\t589.0\t30\t17670.0\t0.22\tNaN\n",
"#1\t07-Mar\t561.0\t32\t17952.0\t0.22\tNaN\n",
"#2\t07-Apr\t640.0\t35\t22400.0\t0.22\tNaN\n",
"#3\t07-May\t656.0\t35\t22960.0\t0.22\tNaN\n",
"#4\t07-Jun\t727.0\t35\t25445.0\t0.22\tNaN"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df['Total Revenue'] = df['Total Milk Production'] * df['Price_Per_Pound']\n",
"df.tail(15)\n",
"\n",
"#Month\tMonthly milk production: pounds per cow\tNumber of Cows\tTotal Milk Production\tPrice_Per_Pound\tTotal Revenue\n",
"#153\t19-Nov\t812.0\t62\t50344.0\t0.32\t16110.08\n",
"#154\t19-Dec\t773.0\t62\t47926.0\t0.32\t15336.32\n",
"#155\t20-Jan\t813.0\t62\t50406.0\t0.32\t16129.92\n",
"#156\t20-Feb\t834.0\t62\t51708.0\t0.32\t16546.56\n",
"#157\t20-Mar\t782.0\t62\t48484.0\t0.32\t15514.88\n",
"#158\t20-Apr\t892.0\t62\t55304.0\t0.32\t17697.28\n",
"#159\t20-May\t903.0\t62\t55986.0\t0.32\t17915.52\n",
"#160\t20-Jun\t966.0\t62\t59892.0\t0.32\t19165.44\n",
"#161\t20-Jul\t937.0\t62\t58094.0\t0.32\t18590.08\n",
"#162\t20-Aug\t896.0\t62\t55552.0\t0.32\t17776.64\n",
"#163\t20-Sep\t858.0\t62\t53196.0\t0.32\t17022.72\n",
"#164\t20-Oct\t755.5\t62\t46841.0\t0.32\t14989.12\n",
"#165\t20-Nov\t755.5\t62\t46841.0\t0.32\t14989.12\n",
"#166\t20-Dec\t797.0\t62\t49414.0\t0.32\t15812.48\n",
"#167\t21-Jan\t843.0\t62\t52266.0\t0.32\t16725.12"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"revenue_2020 = df['Total Revenue'][155:167]\n",
"print(sum(revenue_2020))\n",
"\n",
"#202149.76"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_revenue_2019 = df[155:167]\n",
"df_revenue_2019\n",
"#df_revenue_2019['Total Revenue'].sum()\n",
"\n",
"\n",
"#Month\tMonthly milk production: pounds per cow\tNumber of Cows\tTotal Milk Production\tPrice_Per_Pound\tTotal Revenue\n",
"#155\t20-Jan\t813.0\t62\t50406.0\t0.32\t16129.92\n",
"#156\t20-Feb\t834.0\t62\t51708.0\t0.32\t16546.56\n",
"#157\t20-Mar\t782.0\t62\t48484.0\t0.32\t15514.88\n",
"#158\t20-Apr\t892.0\t62\t55304.0\t0.32\t17697.28\n",
"#159\t20-May\t903.0\t62\t55986.0\t0.32\t17915.52\n",
"#160\t20-Jun\t966.0\t62\t59892.0\t0.32\t19165.44\n",
"#161\t20-Jul\t937.0\t62\t58094.0\t0.32\t18590.08\n",
"#162\t20-Aug\t896.0\t62\t55552.0\t0.32\t17776.64\n",
"#163\t20-Sep\t858.0\t62\t53196.0\t0.32\t17022.72\n",
"#164\t20-Oct\t755.5\t62\t46841.0\t0.32\t14989.12\n",
"#165\t20-Nov\t755.5\t62\t46841.0\t0.32\t14989.12\n",
"#166\t20-Dec\t797.0\t62\t49414.0\t0.32\t15812.48"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
104 changes: 104 additions & 0 deletions 21 Day Challenge/Day 11.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Challenge\n",
"Can Dot spin a profit as an avocado farmer? Examine the data to find the average cost of avocados in Albany in 2017."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv('avocado.csv', index_col = 0)\n",
"df.head()\n",
"\n",
"#Date\tAveragePrice\tTotal Volume\tTotal Bags\tSmall Bags\tLarge Bags\tXLarge Bags\ttype\tyear\tregion\n",
"#0\t2015-12-27\t1.33\t64236.62\t8696.87\t8603.62\t93.25\t0.0\tconventional\t2015\tAlbany\n",
"#1\t2015-12-20\t1.35\t54876.98\t9505.56\t9408.07\t97.49\t0.0\tconventional\t2015\tAlbany\n",
"#2\t2015-12-13\t0.93\t118220.22\t8145.35\t8042.21\t103.14\t0.0\tconventional\t2015\tAlbany\n",
"#3\t2015-12-06\t1.08\t78992.15\t5811.16\t5677.40\t133.76\t0.0\tconventional\t2015\tAlbany\n",
"#4\t2015-11-29\t1.28\t51039.60\t6183.95\t5986.26\t197.69\t0.0\tconventional\t2015\tAlbany"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Solution\n",
"avo = df.groupby(['region','year']).mean()\n",
"avo.head(20)\n",
"\n",
"\n",
"#AveragePrice\tTotal Volume\tTotal Bags\tSmall Bags\tLarge Bags\tXLarge Bags\n",
"#region\tyear\t\t\t\t\t\t\n",
"#Albany\t2015\t1.538750\t38749.004135\t6919.765385\t6744.927404\t173.515865\t1.322115\n",
"#2016\t1.533942\t50618.611442\t8060.576058\t7629.006154\t222.983942\t208.585962\n",
"#2017\t1.637830\t49354.545094\t7882.128302\t4943.011226\t2763.058868\t176.067642\n",
"#2018\t1.435833\t64249.423750\t11949.729167\t9504.018750\t2323.395833\t122.314583\n",
"#Atlanta\t2015\t1.380577\t223381.712692\t28817.219904\t18091.291923\t10717.445673\t8.482308\n",
"#2016\t1.214135\t272373.829808\t95930.159423\t52369.293077\t43229.854712\t331.011635\n",
"#2017\t1.428774\t271840.754528\t110067.614811\t70132.168962\t38002.920189\t1932.516226\n",
"#2018\t1.288750\t342975.935417\t163317.456667\t111701.045417\t50035.261667\t1581.149583\n",
"#BaltimoreWashington\t2015\t1.368846\t390822.880192\t91233.794808\t88677.811635\t2522.575000\t33.408173\n",
"#2016\t1.587596\t393209.637692\t99574.801250\t96155.722885\t2591.820673\t827.257692\n",
"#2017\t1.679434\t386939.947736\t109661.628868\t104926.584717\t3672.241132\t1062.793585\n",
"#2018\t1.378333\t506620.958333\t159913.309167\t157196.139583\t2516.336667\t200.832917\n",
"#Boise\t2015\t1.373750\t36388.051346\t4981.101058\t4641.513846\t323.131346\t16.455865\n",
"#2016\t1.141923\t44745.283942\t22080.516346\t20934.522404\t1099.331250\t46.662692\n",
"#2017\t1.492642\t44910.955755\t19759.427075\t16523.018491\t3212.219057\t24.170660\n",
"#2018\t1.492500\t50614.982083\t20437.698750\t11107.702500\t9274.874583\t55.121667\n",
"#Boston\t2015\t1.473558\t263990.304231\t55372.257788\t54624.526154\t746.329423\t1.402212\n",
"#2016\t1.426154\t293954.952596\t66656.696154\t65671.839423\t635.623365\t349.233365\n",
"#2017\t1.679528\t288779.926038\t66325.052830\t56744.661698\t9218.595472\t361.776792\n",
"#2018\t1.576667\t359875.248333\t73917.082917\t57694.640833\t15803.044167\t419.397917"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"avo.loc[('Albany', 2017)]\n",
"\n",
"#AveragePrice 1.637830\n",
"#Total Volume 49354.545094\n",
"#Total Bags 7882.128302\n",
"#Small Bags 4943.011226\n",
"#Large Bags 2763.058868\n",
"#XLarge Bags 176.067642\n",
"#Name: (Albany, 2017), dtype: float64"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading