Lab/Week 5 Solution




In this week, you have studied additional Python language syntax including File I/O, Exceptions and Object-Oriented Programming. The Lab for this week demonstrates your knowledge of this additional Python functionality. Be sure to use the examples in the textbook reading along with the associate libraries, functions and processes when completing the assignments for this week.

Be sure to develop and test your Python code in the AWS Cloud9 IDE provided for the class.

You should continue to use the PEP Python Style guide mentioned in the book and found here:

Some examples of Python Coding Style best practices include:

Limit all lines to a maximum of 79 characters.

Imports are always put at the top of the file, just after any module comments and before module globals and constants.

Use 4 spaces for indentation. Submission requirements for this project include 4 files. (Zipping them into one file is acceptable and encouraged): Python Data Analysis Code

2 Input Files (Same files supplied to you)

Word, Excel or PDF file containing your test results Python Applications for Lab4: (total 100 points): This exercise (80 points)allows a user to load one of two CSV files and then perform histogram analysis and plots for select variables on the datasets. The first dataset represents the population change for specific dates for U.S. regions. The second dataset represents Housing data over an extended period of time describing home age, number of bedrooms and other variables. The first row provides a column name for each dataset. The following columns should be used to perform analysis: PopChange.csv:

Pop Apr 1

Pop Jul 1

Change Pop Housing.csv:






Notice for the Housing CSV file, there are more columns in the file than are required to be analyzed. You can and should still load each column. Specific statistics options should include:



Standard Deviation



Histogram Hints:

1. Use the Pandas, Numpy, MatplotLib and other Python modules when appropriate.

2. Since you are running this on a Linux box, you don’t really have a graphical environment. So you will need to save the graphics for display. Notice the plt variable is assigned to fig1 and then the figure is saved. For example: import numpy as np import matplotlib.pyplot as plt # Fixing random state for reproducibility np.random.seed(214801) mu, sigma = 100, 15 x = mu + sigma * np.random.randn(10000)  

error: Content is protected !!