#python hw

1 messages · Page 1 of 1 (latest)

junior beacon
#

i know it has smth to do with import pandas as pd i think...

The Question:
Write a program that computes the minimum, average, and maximum 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.
the data file had this in it:

Source: https://en.wikipedia.org/wiki/Demographics_of_New_York_City,,,,,,
All population figures are consistent with present-day boundaries.,,,,,,
First census after the consolidation of the five boroughs,,,,,,
,,,,,,
,,,,,,
Year,Manhattan,Brooklyn,Queens,Bronx,Staten Island,Total
1698,4937,2017,,,727,7681
1771,21863,3623,,,2847,28423
1790,33131,4549,6159,1781,3827,49447
1800,60515,5740,6642,1755,4563,79215
1810,96373,8303,7444,2267,5347,119734
1820,123706,11187,8246,2782,6135,152056
1830,202589,20535,9049,3023,7082,242278
1840,312710,47613,14480,5346,10965,391114
1850,515547,138882,18593,8032,15061,696115
1860,813669,279122,32903,23593,25492,1174779
1870,942292,419921,45468,37393,33029,1478103
1880,1164673,599495,56559,51980,38991,1911698
1890,1441216,838547,87050,88908,51693,2507414
1900,1850093,1166582,152999,200507,67021,3437202
1910,2331542,1634351,284041,430980,85969,4766883
1920,2284103,2018356,469042,732016,116531,5620048
1930,1867312,2560401,1079129,1265258,158346,6930446
1940,1889924,2698285,1297634,1394711,174441,7454995
1950,1960101,2738175,1550849,1451277,191555,7891957
1960,1698281,2627319,1809578,1424815,221991,7781984
1970,1539233,2602012,1986473,1471701,295443,7894862
1980,1428285,2230936,1891325,1168972,352121,7071639
1990,1487536,2300664,1951598,1203789,378977,7322564
2000,1537195,2465326,2229379,1332650,443728,8008278
2010,1585873,2504700,2230722,1385108,468730,8175133
2015,1644518,2636735,2339150,1455444,474558,8550405

A sample run of your program:

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

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

dusky totem
#

well whats the issue here?

junior beacon
#

dunno how to write the program that gets the avg min and max population for a borough entered by the user

broken basin
#

Would it help you to write it down logically without code

junior beacon
#

not sure, i havnt tried that, but so far i only understand the input part, i dont get how i bring the information from the file
So i got so far is this:

import pandas as pd
df = pd.read_csv('nycHistPop.csv') #what my lab showed
borough = input("Enter borough: ")

Im cant get the avg max and min without getting the data of the selected borough first, so how do i get the data