Instantly share code, notes, and snippets.
Created
September 10, 2020 20:02
-
Save alanlujan91/a6fc8bbd507e79c9d6bd7babb3516484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"OSU Make your own Shared Sacrifice - Private Copy.ipynb","provenance":[],"collapsed_sections":[]},"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.8.5"},"widgets":{"application/vnd.jupyter.widget-state+json":{"feaf6333efcb4773977a1444656b6141":{"model_module":"@jupyter-widgets/controls","model_name":"VBoxModel","state":{"_view_name":"VBoxView","_dom_classes":["widget-interact"],"_model_name":"VBoxModel","_view_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","_view_count":null,"_view_module_version":"1.5.0","box_style":"","layout":"IPY_MODEL_adc47ea588c442c8b07e7a56c8134fe0","_model_module":"@jupyter-widgets/controls","children":["IPY_MODEL_87dc21604c564f5eaa4c989ce327cc5f","IPY_MODEL_8c40eb2a065840c6a8694679105eaa5c","IPY_MODEL_ac2aa90cb5aa4283a9743ee4ed6640e1","IPY_MODEL_df764517b79c48ada5c5b77b5c3e5ac0","IPY_MODEL_7be17ab61e1d48c99b5836b5463dc883"]}},"adc47ea588c442c8b07e7a56c8134fe0":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","state":{"_view_name":"LayoutView","grid_template_rows":null,"right":null,"justify_content":null,"_view_module":"@jupyter-widgets/base","overflow":null,"_model_module_version":"1.2.0","_view_count":null,"flex_flow":null,"width":null,"min_width":null,"border":null,"align_items":null,"bottom":null,"_model_module":"@jupyter-widgets/base","top":null,"grid_column":null,"overflow_y":null,"overflow_x":null,"grid_auto_flow":null,"grid_area":null,"grid_template_columns":null,"flex":null,"_model_name":"LayoutModel","justify_items":null,"grid_row":null,"max_height":null,"align_content":null,"visibility":null,"align_self":null,"height":null,"min_height":null,"padding":null,"grid_auto_rows":null,"grid_gap":null,"max_width":null,"order":null,"_view_module_version":"1.2.0","grid_template_areas":null,"object_position":null,"object_fit":null,"grid_auto_columns":null,"margin":null,"display":null,"left":null}},"87dc21604c564f5eaa4c989ce327cc5f":{"model_module":"@jupyter-widgets/controls","model_name":"TextModel","state":{"_view_name":"TextView","style":"IPY_MODEL_bd30aa57b8c24080a3532b073db91f50","_dom_classes":[],"description":"Title:","_model_name":"TextModel","placeholder":"Enter a part of title.","_view_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","value":"coach","_view_count":null,"disabled":false,"_view_module_version":"1.5.0","continuous_update":true,"description_tooltip":null,"_model_module":"@jupyter-widgets/controls","layout":"IPY_MODEL_243de7afdda941178830933faaa4d72e"}},"8c40eb2a065840c6a8694679105eaa5c":{"model_module":"@jupyter-widgets/controls","model_name":"BoundedFloatTextModel","state":{"_view_name":"FloatTextView","style":"IPY_MODEL_45e1a02f2a7344acbf6ad3a0aba3db5e","_dom_classes":[],"description":"Threshold:","_model_name":"BoundedFloatTextModel","max":2000000,"_view_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","value":381855,"_view_count":null,"disabled":false,"_view_module_version":"1.5.0","min":0,"continuous_update":false,"step":1,"description_tooltip":null,"_model_module":"@jupyter-widgets/controls","layout":"IPY_MODEL_660323da184d41dba1fbac0b2213093b"}},"ac2aa90cb5aa4283a9743ee4ed6640e1":{"model_module":"@jupyter-widgets/controls","model_name":"FloatSliderModel","state":{"_view_name":"FloatSliderView","style":"IPY_MODEL_cbb1b3dcd11543e5a1daf83d611387e3","_dom_classes":[],"description":"Salary:","step":1,"_model_name":"FloatSliderModel","orientation":"horizontal","max":2000000,"_view_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","value":381855,"_view_count":null,"disabled":false,"_view_module_version":"1.5.0","min":0,"continuous_update":true,"readout_format":"$,.0f","description_tooltip":null,"readout":true,"_model_module":"@jupyter-widgets/controls","layout":"IPY_MODEL_5d62d68dd018407a9f7b6d602c398d29"}},"df764517b79c48ada5c5b77b5c3e5ac0":{"model_module":"@jupyter-widgets/controls","model_name":"FloatSliderModel","state":{"_view_name":"FloatSliderView","style":"IPY_MODEL_27758547be3545cba7490f42e0f1dda0","_dom_classes":[],"description":"Percent Cut","step":0.01,"_model_name":"FloatSliderModel","orientation":"horizontal","max":1,"_view_module":"@jupyter-widgets/controls","_model_module_version":"1.5.0","value":0.75,"_view_count":null,"disabled":false,"_view_module_version":"1.5.0","min":0,"continuous_update":true,"readout_format":".0%","description_tooltip":null,"readout":true,"_model_module":"@jupyter-widgets/controls","layout":"IPY_MODEL_41cf61506abf484e95acbe20e9670a7a"}},"7be17ab61e1d48c99b5836b5463dc883":{"model_module":"@jupyter-widgets/output","model_name":"OutputModel","state":{"_view_name":"OutputView","msg_id":"","_dom_classes":[],"_model_name":"OutputModel","outputs":[{"output_type":"stream","metadata":{"tags":[]},"text":"\n\n","stream":"stdout"},{"output_type":"display_data","metadata":{"tags":[]},"text/markdown":"# If all the Ohio State University employees with the word \"coach\" in their Title, making over \\$381,855 gave up 75% of their salary, the university could save \\$16,571,001.84 in payroll. Here are at most the top 20 earners and how much of a paycut they would take under this scenario.","text/plain":"<IPython.core.display.Markdown object>"},{"output_type":"stream","metadata":{"tags":[]},"text":"\n\n","stream":"stdout"},{"output_type":"display_data","metadata":{"tags":[]},"text/html":"<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>Name</th>\n <th>Title</th>\n <th>Regular</th>\n <th>Bonus</th>\n <th>Total</th>\n <th>Shared Sacrifice</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>9537</th>\n <td>Day,Ryan Patrick</td>\n <td>Head Coach-Major Sports</td>\n <td>$2,114,255.19</td>\n <td>$2,835,278.57</td>\n <td>$4,949,533.76</td>\n <td>$3,712,150.32</td>\n </tr>\n <tr>\n <th>18227</th>\n <td>Holtmann,Christopher A</td>\n <td>Head Coach-Major Sports</td>\n <td>$1,416,437.68</td>\n <td>$1,415,000.08</td>\n <td>$2,831,437.76</td>\n <td>$2,123,578.32</td>\n </tr>\n <tr>\n <th>45220</th>\n <td>Yurcich,Michael</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$953,758.01</td>\n <td>$693,827.23</td>\n <td>$1,647,585.24</td>\n <td>$1,235,688.93</td>\n </tr>\n <tr>\n <th>25850</th>\n <td>Matta,Thad Michael</td>\n <td>Head Coach-Major Sports</td>\n <td>$nan</td>\n <td>$nan</td>\n <td>$1,591,969.80</td>\n <td>$1,193,977.35</td>\n </tr>\n <tr>\n <th>25882</th>\n <td>Mattison,Gregory</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$1,091,258.01</td>\n <td>$140,250.00</td>\n <td>$1,231,508.01</td>\n <td>$923,631.01</td>\n </tr>\n <tr>\n <th>44083</th>\n <td>Wilson,Kevin R.</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$944,700.04</td>\n <td>$257,125.00</td>\n <td>$1,201,825.04</td>\n <td>$901,368.78</td>\n </tr>\n <tr>\n <th>20021</th>\n <td>Johnson,Larry A.</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$894,940.00</td>\n <td>$242,250.00</td>\n <td>$1,137,190.00</td>\n <td>$852,892.50</td>\n </tr>\n <tr>\n <th>15840</th>\n <td>Hafley,Jeffrey</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$943,431.92</td>\n <td>$121,125.00</td>\n <td>$1,064,556.92</td>\n <td>$798,417.69</td>\n </tr>\n <tr>\n <th>26573</th>\n <td>McGuff,Kevin P</td>\n <td>Head Coach-Major Sports</td>\n <td>$853,994.28</td>\n <td>$200,000.08</td>\n <td>$1,053,994.36</td>\n <td>$790,495.77</td>\n </tr>\n <tr>\n <th>689</th>\n <td>Alford,Anthony J</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$601,190.00</td>\n <td>$165,750.00</td>\n <td>$766,940.00</td>\n <td>$575,205.00</td>\n </tr>\n <tr>\n <th>39278</th>\n <td>Studrawa,Gregory John</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$598,886.67</td>\n <td>$161,500.00</td>\n <td>$760,386.67</td>\n <td>$570,290.00</td>\n </tr>\n <tr>\n <th>35517</th>\n <td>Schiano,Gregory E</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$103,589.13</td>\n <td>$311,250.00</td>\n <td>$587,915.13</td>\n <td>$440,936.35</td>\n </tr>\n <tr>\n <th>42659</th>\n <td>Washington,Alvin</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$499,953.66</td>\n <td>$63,750.00</td>\n <td>$563,703.66</td>\n <td>$422,777.74</td>\n </tr>\n <tr>\n <th>34251</th>\n <td>Rohlik,Steve E</td>\n <td>Head Coach</td>\n <td>$464,940.00</td>\n <td>$76,500.00</td>\n <td>$541,440.00</td>\n <td>$406,080.00</td>\n </tr>\n <tr>\n <th>31263</th>\n <td>Pedon,Ryan Thomas</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$475,491.80</td>\n <td>$nan</td>\n <td>$475,491.80</td>\n <td>$356,618.85</td>\n </tr>\n <tr>\n <th>16752</th>\n <td>Hartline,Brian J</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$378,842.53</td>\n <td>$63,750.00</td>\n <td>$442,592.53</td>\n <td>$331,944.40</td>\n </tr>\n <tr>\n <th>28957</th>\n <td>Myers,Nicholas Gregory</td>\n <td>Head Coach</td>\n <td>$434,950.00</td>\n <td>$nan</td>\n <td>$434,950.00</td>\n <td>$326,212.50</td>\n </tr>\n <tr>\n <th>34840</th>\n <td>Ryan,Thomas Shaun</td>\n <td>Head Coach</td>\n <td>$383,660.28</td>\n <td>$26,818.08</td>\n <td>$410,478.36</td>\n <td>$307,858.77</td>\n </tr>\n <tr>\n <th>2345</th>\n <td>Barnes,Matthew</td>\n <td>Assistant Coach-Major Sports</td>\n <td>$356,545.08</td>\n <td>$44,625.00</td>\n <td>$401,170.08</td>\n <td>$300,877.56</td>\n </tr>\n </tbody>\n</table>\n</div>","text/plain":" Name ... Shared Sacrifice\n9537 Day,Ryan Patrick ... $3,712,150.32\n18227 Holtmann,Christopher A ... $2,123,578.32\n45220 Yurcich,Michael ... $1,235,688.93\n25850 Matta,Thad Michael ... $1,193,977.35\n25882 Mattison,Gregory ... $923,631.01\n44083 Wilson,Kevin R. ... $901,368.78\n20021 Johnson,Larry A. ... $852,892.50\n15840 Hafley,Jeffrey ... $798,417.69\n26573 McGuff,Kevin P ... $790,495.77\n689 Alford,Anthony J ... $575,205.00\n39278 Studrawa,Gregory John ... $570,290.00\n35517 Schiano,Gregory E ... $440,936.35\n42659 Washington,Alvin ... $422,777.74\n34251 Rohlik,Steve E ... $406,080.00\n31263 Pedon,Ryan Thomas ... $356,618.85\n16752 Hartline,Brian J ... $331,944.40\n28957 Myers,Nicholas Gregory ... $326,212.50\n34840 Ryan,Thomas Shaun ... $307,858.77\n2345 Barnes,Matthew ... $300,877.56\n\n[19 rows x 6 columns]"}],"_view_module":"@jupyter-widgets/output","_model_module_version":"1.0.0","_view_count":null,"_view_module_version":"1.0.0","layout":"IPY_MODEL_bc9ccc9d10b44272a92f9327ae2a26e4","_model_module":"@jupyter-widgets/output"}},"bd30aa57b8c24080a3532b073db91f50":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","state":{"_view_name":"StyleView","_model_name":"DescriptionStyleModel","description_width":"","_view_module":"@jupyter-widgets/base","_model_module_version":"1.5.0","_view_count":null,"_view_module_version":"1.2.0","_model_module":"@jupyter-widgets/controls"}},"243de7afdda941178830933faaa4d72e":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","state":{"_view_name":"LayoutView","grid_template_rows":null,"right":null,"justify_content":null,"_view_module":"@jupyter-widgets/base","overflow":null,"_model_module_version":"1.2.0","_view_count":null,"flex_flow":null,"width":null,"min_width":null,"border":null,"align_items":null,"bottom":null,"_model_module":"@jupyter-widgets/base","top":null,"grid_column":null,"overflow_y":null,"overflow_x":null,"grid_auto_flow":null,"grid_area":null,"grid_template_columns":null,"flex":null,"_model_name":"LayoutModel","justify_items":null,"grid_row":null,"max_height":null,"align_content":null,"visibility":null,"align_self":null,"height":null,"min_height":null,"padding":null,"grid_auto_rows":null,"grid_gap":null,"max_width":null,"order":null,"_view_module_version":"1.2.0","grid_template_areas":null,"object_position":null,"object_fit":null,"grid_auto_columns":null,"margin":null,"display":null,"left":null}},"45e1a02f2a7344acbf6ad3a0aba3db5e":{"model_module":"@jupyter-widgets/controls","model_name":"DescriptionStyleModel","state":{"_view_name":"StyleView","_model_name":"DescriptionStyleModel","description_width":"","_view_module":"@jupyter-widgets/base","_model_module_version":"1.5.0","_view_count":null,"_view_module_version":"1.2.0","_model_module":"@jupyter-widgets/controls"}},"660323da184d41dba1fbac0b2213093b":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","state":{"_view_name":"LayoutView","grid_template_rows":null,"right":null,"justify_content":null,"_view_module":"@jupyter-widgets/base","overflow":null,"_model_module_version":"1.2.0","_view_count":null,"flex_flow":null,"width":null,"min_width":null,"border":null,"align_items":null,"bottom":null,"_model_module":"@jupyter-widgets/base","top":null,"grid_column":null,"overflow_y":null,"overflow_x":null,"grid_auto_flow":null,"grid_area":null,"grid_template_columns":null,"flex":null,"_model_name":"LayoutModel","justify_items":null,"grid_row":null,"max_height":null,"align_content":null,"visibility":null,"align_self":null,"height":null,"min_height":null,"padding":null,"grid_auto_rows":null,"grid_gap":null,"max_width":null,"order":null,"_view_module_version":"1.2.0","grid_template_areas":null,"object_position":null,"object_fit":null,"grid_auto_columns":null,"margin":null,"display":null,"left":null}},"cbb1b3dcd11543e5a1daf83d611387e3":{"model_module":"@jupyter-widgets/controls","model_name":"SliderStyleModel","state":{"_view_name":"StyleView","handle_color":null,"_model_name":"SliderStyleModel","description_width":"","_view_module":"@jupyter-widgets/base","_model_module_version":"1.5.0","_view_count":null,"_view_module_version":"1.2.0","_model_module":"@jupyter-widgets/controls"}},"5d62d68dd018407a9f7b6d602c398d29":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","state":{"_view_name":"LayoutView","grid_template_rows":null,"right":null,"justify_content":null,"_view_module":"@jupyter-widgets/base","overflow":null,"_model_module_version":"1.2.0","_view_count":null,"flex_flow":null,"width":null,"min_width":null,"border":null,"align_items":null,"bottom":null,"_model_module":"@jupyter-widgets/base","top":null,"grid_column":null,"overflow_y":null,"overflow_x":null,"grid_auto_flow":null,"grid_area":null,"grid_template_columns":null,"flex":null,"_model_name":"LayoutModel","justify_items":null,"grid_row":null,"max_height":null,"align_content":null,"visibility":null,"align_self":null,"height":null,"min_height":null,"padding":null,"grid_auto_rows":null,"grid_gap":null,"max_width":null,"order":null,"_view_module_version":"1.2.0","grid_template_areas":null,"object_position":null,"object_fit":null,"grid_auto_columns":null,"margin":null,"display":null,"left":null}},"27758547be3545cba7490f42e0f1dda0":{"model_module":"@jupyter-widgets/controls","model_name":"SliderStyleModel","state":{"_view_name":"StyleView","handle_color":null,"_model_name":"SliderStyleModel","description_width":"","_view_module":"@jupyter-widgets/base","_model_module_version":"1.5.0","_view_count":null,"_view_module_version":"1.2.0","_model_module":"@jupyter-widgets/controls"}},"41cf61506abf484e95acbe20e9670a7a":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","state":{"_view_name":"LayoutView","grid_template_rows":null,"right":null,"justify_content":null,"_view_module":"@jupyter-widgets/base","overflow":null,"_model_module_version":"1.2.0","_view_count":null,"flex_flow":null,"width":null,"min_width":null,"border":null,"align_items":null,"bottom":null,"_model_module":"@jupyter-widgets/base","top":null,"grid_column":null,"overflow_y":null,"overflow_x":null,"grid_auto_flow":null,"grid_area":null,"grid_template_columns":null,"flex":null,"_model_name":"LayoutModel","justify_items":null,"grid_row":null,"max_height":null,"align_content":null,"visibility":null,"align_self":null,"height":null,"min_height":null,"padding":null,"grid_auto_rows":null,"grid_gap":null,"max_width":null,"order":null,"_view_module_version":"1.2.0","grid_template_areas":null,"object_position":null,"object_fit":null,"grid_auto_columns":null,"margin":null,"display":null,"left":null}},"bc9ccc9d10b44272a92f9327ae2a26e4":{"model_module":"@jupyter-widgets/base","model_name":"LayoutModel","state":{"_view_name":"LayoutView","grid_template_rows":null,"right":null,"justify_content":null,"_view_module":"@jupyter-widgets/base","overflow":null,"_model_module_version":"1.2.0","_view_count":null,"flex_flow":null,"width":null,"min_width":null,"border":null,"align_items":null,"bottom":null,"_model_module":"@jupyter-widgets/base","top":null,"grid_column":null,"overflow_y":null,"overflow_x":null,"grid_auto_flow":null,"grid_area":null,"grid_template_columns":null,"flex":null,"_model_name":"LayoutModel","justify_items":null,"grid_row":null,"max_height":null,"align_content":null,"visibility":null,"align_self":null,"height":null,"min_height":null,"padding":null,"grid_auto_rows":null,"grid_gap":null,"max_width":null,"order":null,"_view_module_version":"1.2.0","grid_template_areas":null,"object_position":null,"object_fit":null,"grid_auto_columns":null,"margin":null,"display":null,"left":null}}}}},"cells":[{"cell_type":"markdown","metadata":{"colab_type":"text","id":"paZ4frhBtWRG"},"source":["# Intro"]},{"cell_type":"code","metadata":{"colab_type":"code","id":"YxV7hlDuVkIM","colab":{},"executionInfo":{"status":"ok","timestamp":1599766498280,"user_tz":240,"elapsed":676,"user":{"displayName":"Alan Lujan","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GguP1ryfN6D3hW7ri_agYloLSyIKtP3xAB3JaBfy94=s64","userId":"12180905711796180284"}}},"source":["import pandas as pd\n","from IPython.core.display import Markdown\n","from ipywidgets import interact, widgets"],"execution_count":1,"outputs":[]},{"cell_type":"code","metadata":{"colab_type":"code","id":"63pDtcCPVyh8","colab":{},"executionInfo":{"status":"ok","timestamp":1599766498282,"user_tz":240,"elapsed":672,"user":{"displayName":"Alan Lujan","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GguP1ryfN6D3hW7ri_agYloLSyIKtP3xAB3JaBfy94=s64","userId":"12180905711796180284"}}},"source":["url = \"https://apps.hr.osu.edu/public/documents/salaries/2019-Earnings-Combined.xlsx\"\n","# database = pd.read_excel(url)\n","# database.to_pickle(\"database.pkl\")\n","database = pd.read_pickle(\"database.pkl\")"],"execution_count":2,"outputs":[]},{"cell_type":"code","metadata":{"colab_type":"code","id":"Gg5HiHbBkoOv","colab":{"base_uri":"https://localhost:8080/","height":218},"executionInfo":{"status":"ok","timestamp":1599766498283,"user_tz":240,"elapsed":660,"user":{"displayName":"Alan Lujan","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GguP1ryfN6D3hW7ri_agYloLSyIKtP3xAB3JaBfy94=s64","userId":"12180905711796180284"}},"outputId":"a6545160-3f4d-4b7d-fd5b-03bbf2b36fdf"},"source":["salaries = database[[\"Name\", \"Title\", \"Regular\", \"Bonus\", \"Total\"]].copy()\n","salaries = salaries.sort_values(by=\"Total\", ascending=False)\n","salaries.info()"],"execution_count":3,"outputs":[{"output_type":"stream","text":["<class 'pandas.core.frame.DataFrame'>\n","Int64Index: 45695 entries, 9537 to 12341\n","Data columns (total 5 columns):\n"," # Column Non-Null Count Dtype \n","--- ------ -------------- ----- \n"," 0 Name 45695 non-null object \n"," 1 Title 45695 non-null object \n"," 2 Regular 45586 non-null float64\n"," 3 Bonus 22064 non-null float64\n"," 4 Total 45695 non-null float64\n","dtypes: float64(3), object(2)\n","memory usage: 2.1+ MB\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"cellView":"form","colab_type":"code","id":"0s29bPMuVTTp","colab":{},"executionInfo":{"status":"ok","timestamp":1599766498689,"user_tz":240,"elapsed":1064,"user":{"displayName":"Alan Lujan","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GguP1ryfN6D3hW7ri_agYloLSyIKtP3xAB3JaBfy94=s64","userId":"12180905711796180284"}}},"source":["# @title Widget Set up\n","title_widget = widgets.Text(\n"," value=\"coach\", placeholder=\"Enter a part of title.\", description=\"Title:\"\n",")\n","salary_slider = widgets.FloatSlider(\n"," value=1e5,\n"," min=0,\n"," max=2e6,\n"," step=1,\n"," description=\"Salary:\",\n"," readout=True,\n"," readout_format=\"$,.0f\",\n",")\n","salary_box = widgets.BoundedFloatText(\n"," value=1e5, min=0, max=2e6, step=1, description=\"Threshold:\", format=\"$,.2f\"\n",")\n","\n","\n","def update_slider(*args):\n"," salary_slider.value = salary_box.value\n","\n","\n","def update_box(*args):\n"," salary_box.value = salary_slider.value\n","\n","\n","salary_box.observe(update_slider, \"value\")\n","salary_slider.observe(update_box, \"value\")\n","\n","percent_slider = widgets.FloatSlider(\n"," value=0.1,\n"," min=0,\n"," max=1,\n"," step=0.01,\n"," description=\"Percent Cut\",\n"," readout=True,\n"," readout_format=\".0%\",\n",")"],"execution_count":4,"outputs":[]},{"cell_type":"code","metadata":{"cellView":"form","colab_type":"code","id":"a7NB7sXCV2VQ","colab":{"base_uri":"https://localhost:8080/","height":966,"referenced_widgets":["feaf6333efcb4773977a1444656b6141","adc47ea588c442c8b07e7a56c8134fe0","87dc21604c564f5eaa4c989ce327cc5f","8c40eb2a065840c6a8694679105eaa5c","ac2aa90cb5aa4283a9743ee4ed6640e1","df764517b79c48ada5c5b77b5c3e5ac0","7be17ab61e1d48c99b5836b5463dc883","bd30aa57b8c24080a3532b073db91f50","243de7afdda941178830933faaa4d72e","45e1a02f2a7344acbf6ad3a0aba3db5e","660323da184d41dba1fbac0b2213093b","cbb1b3dcd11543e5a1daf83d611387e3","5d62d68dd018407a9f7b6d602c398d29","27758547be3545cba7490f42e0f1dda0","41cf61506abf484e95acbe20e9670a7a","bc9ccc9d10b44272a92f9327ae2a26e4"]},"executionInfo":{"status":"ok","timestamp":1599766498690,"user_tz":240,"elapsed":1059,"user":{"displayName":"Alan Lujan","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GguP1ryfN6D3hW7ri_agYloLSyIKtP3xAB3JaBfy94=s64","userId":"12180905711796180284"}},"outputId":"b56d8a62-34f0-47d5-a2f2-60eccdb1b8c2"},"source":["# @title Make your own \"Shared Sacrifice\" Scenario\n","@interact(\n"," salary_threshold=salary_slider,\n"," percent=percent_slider,\n"," title=title_widget,\n"," salary=salary_box,\n",")\n","def show_table(title, salary, salary_threshold, percent):\n"," shared_sacrifice = salaries[\n"," salaries[\"Title\"].str.contains(title, case=False)\n"," ].copy() # select by title\n"," shared_sacrifice = shared_sacrifice.loc[\n"," shared_sacrifice[\"Total\"] > salary_threshold\n"," ] # select above threshold\n"," shared_sacrifice[\"Shared Sacrifice\"] = (\n"," shared_sacrifice[\"Total\"] * percent\n"," ) # calculate cut\n"," total_cut = shared_sacrifice[\"Shared Sacrifice\"].sum()\n"," columns_to_format = [\"Regular\", \"Bonus\", \"Total\", \"Shared Sacrifice\"]\n"," for column in columns_to_format:\n"," shared_sacrifice[column] = shared_sacrifice[column].apply(\n"," \"${:,.2f}\".format\n"," ) # apply formatting\n"," message = f\"\"\"# If all the Ohio State University employees with the word \"{title}\" \\\n"," in their Title, making over \\\\${salary_threshold:,.0f} gave up {percent:.0%} of \\\n"," their salary, the university could save \\\\${total_cut:,.2f} in payroll. Here are at most \\\n"," the top 20 earners and how much of a paycut they would take under this scenario.\"\"\"\n"," print(\"\\n\")\n"," display(Markdown(message))\n"," print(\"\\n\")\n"," return shared_sacrifice.head(20)"],"execution_count":5,"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.widget-view+json":{"model_id":"feaf6333efcb4773977a1444656b6141","version_minor":0,"version_major":2},"text/plain":["interactive(children=(Text(value='coach', description='Title:', placeholder='Enter a part of title.'), Bounded…"]},"metadata":{"tags":[]}}]},{"cell_type":"code","metadata":{"id":"hYiMTB-JgX-p","colab_type":"code","colab":{},"executionInfo":{"status":"ok","timestamp":1599766498691,"user_tz":240,"elapsed":1055,"user":{"displayName":"Alan Lujan","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GguP1ryfN6D3hW7ri_agYloLSyIKtP3xAB3JaBfy94=s64","userId":"12180905711796180284"}}},"source":[""],"execution_count":5,"outputs":[]}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment