Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lab08S ExternalPackages

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

BUSN5101: Programming for Business

Lab Eight: External Packages

Lab Eight: External Packages


Through the completion of this lab, you should be able to:

- understand and revise the use of ndarrays in program design;

- understand and revise the use of pandas in the design of data analysis programs;

- understand and revise the use of pandas in the implementation of data analysis programs.

The above statements are the learning outcomes of this laboratory and will be achieved in concert
with the other learning activities that you undertake for this unit.

Task One: Using ndarrays with numeric data


1. Utilising Pseudocode, design a program which generates a list of even whole numbers between
0 and 22 inclusive. Utilise the appropriate function to create a ndarray (numpy Array) with one
row and twelve columns (1x12) that stores this data from this list. Next, reshape this ndarray
so it is in the format of a 4x3 and a 3x4 ndarray, outputting both arrays to the user. Finally,
divide each element of the original array by two and output this changed array in the format of a
1x12 ndarray.

2. Convert your Pseudocode to Python code. If you are using Visual Studio Code, use pip to
install numpy and ensure you have created and utilised a new Workspace for this week. Then,
run the code and note any errors that you encounter. Correct any errors in your Pseudocode
and Python code and run it again, repeating until all errors are fixed.

Task Two: Processing and analysing data with pandas


3. The “Western Australia Budget Economic and Fiscal Outlook” for Financial Year 2015/2016 is a
financial report prepared by the Government of Western Australia. It details the actual,
budgeted and forward estimates of expenses for the state government. Appendix 8 of the
“Table and Chart Data” details the overall funding provided to various government operating
entities. Complete the following steps to begin your journey processing this data:

a. Firstly, download the tables from the Data WA open data portal by clicking the
“Download” button to the right of the large “Appendix 8” button as an Excel file – the
default option (click here).

b. Once you have done so, write Python code to read in Table 8.7 from the file using the
read_excel function, noting the specification of the sheet name from the
documentation (click here).

c. Print the DataFrame once it has been created and note its dimensions.

d. Then, remove any rows that contain cells with no data (as well as the first row with
column headers) and print the DataFrame again, noting the difference in dimensions.

e. Then, remove any rows that have quasi-no data (i.e. those with elements consisting of “-”
or “-(d)”). This can be achieved using the ‘tilde’ operator negating a statement (e.g.
~(the_df[“Column”] == “Value) as an expression). You may wish to output the
table to see if you have removed all elements in the process.

f. Finally, filter out any rows that are for values less than $5m in either the final financial
year or the one before it. Print the DataFrame again, noting the difference in dimensions.

g. Output descriptive statistics to the user. Postulate why they have been output the way
they have. Then, output the result to a CSV file named processed_data.csv.

UWA Business School Page 1 of 2


CRICOS: 00126G | PRV12169, Australian University
BUSN5101: Programming for Business
Lab Eight: External Packages

Task Three: Revision


4. Spend any remaining time you have revising previous materials you have used or work for
exercises you have created for this unit.

End of Lab Eight.

UWA Business School Page 2 of 2


CRICOS: 00126G | PRV12169, Australian University

You might also like