Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a couple of CSV files that I built and am trying to find the best way to put together a python language program

I have a couple of CSV files that I built and am trying to find the best way to put together a python language program that will allow a user to load one of two of these CSV files and then perform histogram analysis as well as 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:

AGE

BEDRMS

BUILT

ROOMS

UTILITY

If an inappropriate entry is detected, the program should prompt for a correct value and continue to do

so until a correct value is entered.

After the program opens up either CSV files I am wanting to use the python code below to read them.

semesters = list()

with open(filename,'r') as s:

reader = csv.reader(s)

next(reader) # skip the header

for line in reader:

# Append the soc record to the list

semesters.append(objs.SEMESTER(line))

semesters.append(objs.SEMESTER(line))

class SEMESTER:

# Extract the critical data (maybe all of the data in a class)

def __init__(self, line):

self.data =line

# Go through each element and assign value

self.strm = self.data[0].strip()

self.session = self.data[1].strip()

self.startdate = self.data[2].strip()

2

Notice for the Housing CSV file, there are more columns in the file than are required to be analyzed. I am trying to set it up so that the program loads all the columns.

The Specific statistics options should include:

Count

Mean

Standard Deviation

Min

Max

Histogram

Below is my desired output format:

the file you want to analyze:

1. Population Data

2. Housing Data

3. Exit the Program

4

1

You have entered Population Data.

Select the Column you want to analyze:

a. Pop Apr 1

b. Pop Jul 1

c. Change Pop

d. Exit Column

a

You selected Pop Apr 1

The statistics for this column are:

Count = 10000

Mean = 32.5

Standard Deviation = 4.5

Min = 53.2

Max = 12.5

The Histogram of this column can be downloaded now.

Select the Column you want to analyze:

a. Pop Apr 1

b. Pop Jul 1

c. Change Pop

d. Exit Column

d

You selected to exit the column menu

Select the file you want to analyze:

1. Population Data

2. Housing Data

3. Exit the Program

3

*************** Thanks for using the Data Analysis App**********

Here is the csv file information I gathered.

PopChange.csv

Id,Geography,Target Geo Id,Target Geo Id2,Pop Apr 1,Pop Jul 1,Change Pop

0100000US,United States,310M400US10100,10100,40603,43191,2588

0100000US,United States,310M400US10140,10140,72798,73901,1103

0100000US,United States,310M400US10220,10220,37490,38247,757

0100000US,United States,310M400US10300,10300,99892,98266,-1626

0100000US,United States,310M400US10460,10460,63832,66781,2949

0100000US,United States,310M400US10620,10620,60586,62075,1489

0100000US,United States,310M400US10660,10660,31254,30444,-810

0100000US,United States,310M400US10700,10700,93019,96109,3090

0100000US,United States,310M400US10760,10760,41618,40497,-1121

Housing.csv

AGE,BEDRMS,BUILT,NUNITS,ROOMS,WEIGHT,UTILITY

82,2,2006,1,6,3117.394239,169

50,4,1980,1,6,2150.725544,245.3333333

53,4,1985,1,7,2213.789404,159

67,3,1985,1,6,2364.585097,179

26,2,1980,100,4,2314.524902,146

56,1,1985,32,3,2482.655916,94.75

50,3,1985,1,6,4084.310118,236

26,2,1980,8,5,2823.39599,81

60,3,1985,1,7,2552.762241,184.0833333

26,1,1985,24,3,2845.454432,0

59,3,1985,1,5,2150.592362,172

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

Step: 3

blur-text-image

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