Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Where did I go wrong and why please. import numpy as np import matplotlib.pyplot as plt import pandas as pd # read the housing csv

Where did I go wrong and why please.

import numpy as np import matplotlib.pyplot as plt import pandas as pd # read the housing csv hs_df = pd.read_csv("Housing.csv") # read the pop change csv pop_df = pd.read_csv("PopChange.csv") # display the menu def menu(): """print a menu for the user to use in the data analysis application""" print(' Select the file you want to analyze: ') print('1: Population Data ') print('2: Housing Data ') print('3: Exit the application') # display options for population data def pop_data_column(): """print the menu for the user to use in the pop data column""" print(' You have entered Population Data ') print(' Select the Column you want to analyze: ') print('a: Pop Apr 1 ') print('b: Pop Jul 1 ') print('c: Change Pop') print('d: Exit Column') # display Pop Apr 1 statistics def pop_apr_1(): """print the menu for the user to use in the pop data column""" print(' You have selected Pop Apr 1') print(' The statistics for this column are: ') print('Count = ', pop_df["Pop Apr 1"].count()) print('Mean = ', pop_df["Pop Apr 1"].mean()) print('Standard Deviation = ', pop_df["Pop Apr 1"].std()) print('Max = ', pop_df["Pop Apr 1"].max()) n, bins, patches = plt.hist(pop_df["Pop Apr 1"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('pop_Apr_1.svg') print('**** The Histogram of this column can be downloaded now ****') # display Pop Jul 1 statistics def pop_jul_1(): """print the menu for the user to use in the pop data column""" print(' You have selected Pop Jul 1') print(' The statistics for this column are: ') print('Count = ', pop_df["Pop Jul 1"].count()) print('Mean = ', pop_df["Pop Jul 1"].mean()) print('Standard Deviation = ', pop_df["Pop Jul 1"].std()) print('Max = ', pop_df["Pop Jul 1"].max()) n, bins, patches = plt.hist(pop_df["Pop Jul 1"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('pop_Jul_1.svg') print('**** The Histogram of this column can be downloaded now ****') # display change_pop statistics def change_pop(): """print the menu for the user to use in the change pop column""" print(' You have selected Change Pop') print(' The statistics for this column are: ') print('Count = ', pop_df["Change Pop"].count()) print('Mean = ', pop_df["Change Pop"].mean()) print('Standard Deviation = ', pop_df["Change Pop"].std()) print('Max = ', pop_df["Change Pop"].max()) n, bins, patches = plt.hist(pop_df["Change Pop"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('change_pop.svg') print('**** The Histogram of this column can be downloaded now ****') # exit the column def exit_column(): """Bring user back to main menu""" menu() # display options for housing data def housing_data(): """print the menu for the user to use in the pop data column""" print(' You have entered Population Data ') print(' Select the Column you want to analyze: ') print('a: Age ') print('b: Bedrooms ') print('c: Built') print('d: N Units') print('e: Rooms') print('f: Weight') print('g: Utility') print('h: Exit Column') # display age statistics def age(): """print the menu for the user to use in the age column""" print(' You have selected Age') print(' The statistics for this column are:') print('Count = ', hs_df["AGE"].count()) print('Mean = ', hs_df["AGE"].mean()) print('Standard Deviation = ', hs_df["AGE"].std()) print('Max = ', hs_df["AGE"].max()) n, bins, patches = plt.hist(hs_df["AGE"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('age.svg') print('**** The Histogram of this column can be downloaded now ****') # display bedroom statistics def bedrooms(): """print the menu for the user to use in the Bedrooms column""" print(' You have selected Bedrooms') print(' The statistics for this column are:') print('Count = ', hs_df["BEDRMS"].count()) print('Mean = ', hs_df["BEDRMS"].mean()) print('Standard Deviation = ', hs_df["BEDRMS"].std()) print('Max = ', hs_df["BEDRMS"].max()) n, bins, patches = plt.hist(hs_df["BEDRMS"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('bedrooms.svg') print('**** The Histogram of this column can be downloaded now ****') # display built statistics def built(): """print the menu for the user to use in the Bedrooms column""" print(' You have selected Bedrooms') print(' The statistics for this column are:') print('Count = ', hs_df["BUILT"].count()) print('Mean = ', hs_df["BUILT"].mean()) print('Standard Deviation = ', hs_df["BUILT"].std()) print('Max = ', hs_df["BUILT"].max()) n, bins, patches = plt.hist(hs_df["BUILT"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('built') print('**** The Histogram of this column can be downloaded now ****') # display NUnits statistics def n_units(): """print the menu for the user to use in the NUnits column""" print(' You have selected NUnits') print(' The statistics for this column are:') print('Count = ', hs_df["NUNITS"].count()) print('Mean = ', hs_df["NUNITS"].mean()) print('Standard Deviation = ', hs_df["NUNITS"].std()) print('Max = ', hs_df["NUNITS"].max()) n, bins, patches = plt.hist(hs_df["NUNITS"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('n_units.svg') print('**** The Histogram of this column can be downloaded now ****') # display Rooms statistics def rooms(): """print the menu for the user to use in the Rooms column""" print(' You have selected Rooms') print(' The statistics for this column are:') print('Count = ', hs_df["ROOMS"].count()) print('Mean = ', hs_df["ROOMS"].mean()) print('Standard Deviation = ', hs_df["ROOMS"].std()) print('Max = ', hs_df["ROOMS"].max()) n, bins, patches = plt.hist(hs_df["ROOMS"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('rooms.svg') print('**** The Histogram of this column can be downloaded now ****') # display Weight statistics def weight(): """print the menu for the user to use in the Weight column""" print(' You have selected Weight') print(' The statistics for this column are:') print('Count = ', hs_df["WEIGHT"].count()) print('Mean = ', hs_df["WEIGHT"].mean()) print('Standard Deviation = ', hs_df["WEIGHT"].std()) print('Max = ', hs_df["WEIGHT"].max()) n, bins, patches = plt.hist(hs_df["WEIGHT"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('weight.svg') print('**** The Histogram of this column can be downloaded now ****') # display Utility statistics def utility(): """print the menu for the user to use in the Utility column""" print(' You have selected Utility') print(' The statistics for this column are:') print('Count = ', hs_df["UTILITY"].count()) print('Mean = ', hs_df["UTILITY"].mean()) print('Standard Deviation = ', hs_df["UTILITY"].std()) print('Max = ', hs_df["UTILITY"].max()) n, bins, patches = plt.hist(hs_df["UTILITY"], 20, density=True, facecolor='b', alpha=0.75) plt.grid(True) plt.show() fig = plt fig.savefig('utility.svg') print('**** The Histogram of this column can be downloaded now ****') print('**** Welcome to the Python Data Analysis Application ****') while True: menu() # Prompt user for input SELECTION = input('Please enter your choice: ') if SELECTION == '1': pop_data_column() USER_CHOICE = input('Please make your choice: ') if USER_CHOICE == 'A' or USER_CHOICE == 'a': pop_apr_1() elif USER_CHOICE == 'B' or USER_CHOICE == 'b': pop_jul_1() elif USER_CHOICE == 'C' or USER_CHOICE == 'c': change_pop() elif USER_CHOICE == 'D' or USER_CHOICE == 'd': exit_column() break else: print('Please enter a, b, c, or d.') pop_data_column() if SELECTION == '2': housing_data() USER_CHOICE = input('Please make your choice: ') if USER_CHOICE == 'A' or USER_CHOICE == 'a': age() elif USER_CHOICE == 'B' or USER_CHOICE == 'b': bedrooms() elif USER_CHOICE == 'C' or USER_CHOICE == 'c': built() elif USER_CHOICE == 'D' or USER_CHOICE == 'd': n_units() elif USER_CHOICE == 'E' or USER_CHOICE == 'e': rooms() elif USER_CHOICE == 'F' or USER_CHOICE == 'f': weight() elif USER_CHOICE == 'G' or USER_CHOICE == 'g': utility() elif USER_CHOICE == 'h' or USER_CHOICE == 'h': exit_column() break else: print('Please enter a, b, c, d, e, f, g, or h.') housing_data() if SELECTION == '3': print('You selected 3.') print('Thanks for using the Data Analysis Application') break else: print('Invalid input, please try again') 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

What are four capabilities of Google Apps for Work?

Answered: 1 week ago