100%(11)11 out of 11 people found this document helpful
This preview shows page 1 - 4 out of 17 pages.
The preview shows page 3 - 4 out of 17 pages.
lab04October 8, 20181Lab 4: Functions and VisualizationsWelcome to Lab 4! This week, we’ll learn about functions, table methods such asapply, and howto generate visualizations!Recommended Reading:•Applying a Function to a Column•VisualizationsFirst, set up the notebook by running the cell below.In :importnumpyasnpfromdatascienceimport*# These lines set up graphing capabilities.importmatplotlib%matplotlibinlineimportmatplotlib.pyplotaspltplt.style.use('fivethirtyeight')importwarningswarnings.simplefilter('ignore',FutureWarning)fromipywidgetsimportinteract, interactive, fixed, interact_manualimportipywidgetsaswidgetsfromclient.api.notebookimportNotebookok=Notebook('lab04.ok')_=ok.auth(inline=True)=====================================================================Assignment: Functions and VisualizationsOK, version v1.12.5=====================================================================Successfully logged in as [email protected]1
1.11. Functions and CEO IncomesIn this question, we’ll look at the 2015 compensation of CEOs at the 100 largest companies inCalifornia. The data was compiled from aLos Angeles Times analysis, and ultimately came fromfilingsmandated by the SEC from all publicly-traded companies. Two companies have two CEOs,so there are 102 CEOs in the dataset.We’ve copied the raw data from the LA Times page into a file calledraw_compensation.csv.(The page notes that all dollar amounts are in millions of dollars.)In :raw_compensation=Table.read_table('raw_compensation.csv')raw_compensationOut:Rank | Name| Company (Headquarters)| Total Pay | % Change1| Mark V. Hurd*| Oracle (Redwood City)| $53.25| (No previous2| Safra A. Catz*| Oracle (Redwood City)| $53.24| (No previous3| Robert A. Iger| Walt Disney (Burbank)| $44.91| -3%4| Marissa A. Mayer| Yahoo! (Sunnyvale)| $35.98| -15%5| Marc Benioff| salesforce.com (San Francisco) | $33.36| -16%6| John H. Hammergren | McKesson (San Francisco)| $24.84| -4%7| John S. Watson| Chevron (San Ramon)| $22.04| -15%8| Jeffrey Weiner| LinkedIn (Mountain View)| $19.86| 27%9| John T. Chambers** | Cisco Systems (San Jose)| $19.62| 19%10| John G. Stumpf| Wells Fargo(San Francisco)| $19.32| -10%... (92 rows omitted)Question 1.We want to compute the average of the CEOs’ pay. Try running the cell below.
Get answer to your question and much more
---> 70ret = umr_sum(arr, axis, dtype, out, keepdims)71if isinstance(ret, mu.ndarray):72ret = um.true_divide(TypeError: cannot perform reduce with flexible typeYou should see an error. Let’s examine why this error occurred by looking at the values in the"Total Pay" column. Use thetypefunction and settotal_pay_typeto the type of the first value inthe "Total Pay" column.