217k views
0 votes
Write a program that computes the minimum, maximum, average and standard deviation of the population over time for a borough (entered by the user). Your program should assume that the NYC historical population data file, nycHistPop.csv is in the same directory.A sample run of your program:

Enter borough: Staten Island
Average population: 139814.23076923078
Maximum population: 474558
and another run:

Enter borough: Brooklyn
Average population: 1252437.5384615385
Maximum population: 2738175

User Kyrbi
by
5.1k points

1 Answer

4 votes

Answer:

import pandas as pd #importing pandas library as pd

import matplotlib.pyplot as plt #importing matplotlib.pyplot as plt

pop=pd.read_csv('nycHistPop.csv') #reading the csv file

borough=input('Enter borough name:') #asking the user for borough namme

# image=input('Enter image name:')

# pop['Fraction']=pop[borough]/pop['Total']

# pop.plot(x='Year', y='Fraction')

print("Minimum population",pop[borough].min()) #printing the minimum population of borough

print("Maximum population",pop[borough].max()) #printing the maximum population of borough

print("Average population",pop[borough].mean()) #printing the average population of borough

print("Standard deviation",pop[borough].std()) #printing the standard deviation of borough

# fig=plt.gcf()

# fig.savefig(image)

Step-by-step explanation:

User Milkywayfarer
by
5.0k points