Question

In: Computer Science

Given a csv file named “result_niwtawq.csv”, extract the data from it. Store the first column data...

Given a csv file named “result_niwtawq.csv”, extract the data from it. Store the first column data to a list named time, second column data to a list named Turb_annual_avg, third column data to a list named Turb_min, fourth column data to a list named Turb_max, fifth column data to a list named Turb_mean. Calculate and write the average, maximumand minimumof Turb_min to a file named “lab3_output.txt”.

https://dropbox.cse.sc.edu/pluginfile.php/256369/mod_assign/introattachment/0/result_niwtawq.csv?forcedownload=1

Solutions

Expert Solution

CODE :

# import modules

import pandas as pd
import numpy as np

# read data from csv file to data frame

data = pd.read_csv("result_niwtawq.csv")

# Store the first column data to a list named time

time = data.iloc[:, 0].tolist()

# store second column data to a list named Turb_annual_avg

Turb_annual_avg = data.iloc[:, 1].tolist()

# store third column data to a list named Turb_min

Turb_min = data.iloc[:, 2].tolist()

# store fourth column data to a list named Turb_max

Turb_max = data.iloc[:, 3].tolist()

# store fifth column data to a list named Turb_mean

Turb_mean = data.iloc[:, 4].tolist()

# Calculate and write the average, maximum and minimum of Turb_min

average = np.mean(Turb_min)
maximum = np.max(Turb_min)
minimum = np.min(Turb_min)

# Open lab3_output.txt file

output_file = open("lab3_output.txt", "w")

# Write data to file

output_file.write("{}, {}, {}".format(average, maximum, minimum))

# Close the file

output_file.close()

SCREENSHOT :


Related Solutions

Python I am creating a program that allows a user to extract data from a .csv...
Python I am creating a program that allows a user to extract data from a .csv file and print the statistics of a certain column in that file. The statistics include Count, Mean, Standard Deviation, Min, and Max. Here is the code I have so far: import csv import json class POP: """ Extract the data """ def __init__(self, line): self.data = line # get elements self.id = self.data[0].strip() self.geography = self.data[1].strip() self.targetGeoId = self.data[2].strip() self.targetGeoId2 = self.data[3].strip() self.popApr1 =...
Using the data from the csv file, answer the questions with rstudio # number_children - The...
Using the data from the csv file, answer the questions with rstudio # number_children - The number of children in the home # internet - Does the home have internet access? # mode - The way the household took the survey # own - Do the residents own with or without a mortgage or rent? # language - The primary language spoken in the home # decade_built - The decade the home was built 1) In how many households, wife’s...
Given the matrix A (2x2 matrix taking the first two column vectors from the input file),...
Given the matrix A (2x2 matrix taking the first two column vectors from the input file), compute the followings. Λ: the diagonal matrix whose diagonal elements are the corresponding eignevalues Λii = λi for i=1,2 R: the 2x2 matrix whose ith column vector is the eigenvector corresponding to λi for i=1,2 RΛRT: the matrix compositions 1/0: the comparison between A and RΛRT (is A= RΛRT?) Your output should have seven lines where the first two lines correspond to the 2x2...
Find the data for the problem in the first worksheet named LightbulbLife of the data file....
Find the data for the problem in the first worksheet named LightbulbLife of the data file. It gives the data on the lifetime in hours of a sample of 100 lightbulbs. The company manufacturing these bulbs wants to know whether it can claim that its lightbulbs typically last more than 1000 burning hours. So it did a study. Identify the null and the alternate hypotheses for this study. Can this lightbulb manufacturer claim at a significance level of 5% that...
PYTHON LANGUAGE Write the data in variable artist_songs into a csv file, 'songs.txt', where the first...
PYTHON LANGUAGE Write the data in variable artist_songs into a csv file, 'songs.txt', where the first column is singer name and second column is a song name. Each line should have a singer and a song name. Use "Name" and "Song" as headers. Do not include double quotation marks (") in your CSV but you should include apostrophes where necessary (for example, for the song "We Don't Talk Anymore"). In [110]: artist_songs = { 'Taylor Swift': ['Love Story', 'You need...
How to read the given structure from a random CSV file separated by commas(which contains no...
How to read the given structure from a random CSV file separated by commas(which contains no headers only the values of the contents of the structure) and then insert in a binary search tree using one of the structure contents as a key i.e. datetime and handle duplicates in binary search tree by implementing link_list.Please develop a C code for this. struct data{ char biker_id[200]; char distance_bike_travelled[200]; char datetime[200]; char count_tripr[200]; }
Create a program that parses a CSV file of product data and prints the items with...
Create a program that parses a CSV file of product data and prints the items with a price that is less than or equal to that input by the user. • Your program should take two arguments: an input file to process and a price limit. • Print only the names of each item to stdout that have a price less than or equal to the given limit. • If the given file does not exist or cannot be opened,...
When using the import wizard in MATLAB to import data fro, a .csv file the data...
When using the import wizard in MATLAB to import data fro, a .csv file the data appears in MATLAB in the following format "35:53.2" how do I convert this into more usable matlab values? I think that the duration function was used to generate the time format. The code will need to be written in MATLAB software I will leave feedback if you are able to provide a correct response. Thank you
I have a CSV file with 6 column Issue id action id Issue category Issue date...
I have a CSV file with 6 column Issue id action id Issue category Issue date Issue Closed Date Issue Type Please write a code in Python that counts the number of issues in each category and the earliest and latest issue date for each category. Example of csv Issue id action id Issue category Issue date Issue Closed Date Issue Type 23 1 Noise Complaint 7/19/2020 7/22/2020 Client Complaint 24 1 Cleanliness Complaint 7/19/2020 7/23/2020 Sanitation 25 2 Site...
Write a Python script that performs brute force to extract a password protected zip file named...
Write a Python script that performs brute force to extract a password protected zip file named sec2.zip. The password is believed to be associated with one of the dictionary word in the 'wordlist.txt file. a) Paste your code here b) What is the password?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT