Question

Description Download hw6_numpy_wine.csv as the source file, each row in the data file is some metrics about one type of win

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

# importing the numpy module
import numpy as np

# read_from_from function that reads a csv file and returns an 2D nd-array
def read_from_file(path):
  
data = np.genfromtxt(path, delimiter=',',skip_header=1)

# returning the 2D nd-array
return data

# Function call
arr = read_from_file("hw6_numpy_wine.csv")

# Displaying the result after function call
print("wine data: \n",arr)

# get_combined_acidity function that returns the combined acid level af all input wine types
def get_combined_acidity(arr):

# Adding the fixed acidity, volatile acidity and citric acid columns
combined = arr[:,0]+arr[:,1]+arr[:,2]

# returning the resultant 1D array
return combined

combined_acid = get_combined_acidity(arr)
print("Combined acidity: \n",combined_acid)

Indentation:

# importing the numpy module import numpy as np # read_from_from function that reads a csv file and returns an 2D nd-array de

Sample Run:

wine data: [[ 7.4 0.7 [ 7.8 0.88 [ 7.8 0.76 0. 0. 0.04 ... ... ... 0.56 0.68 0.65 9.4 9.8 9.8 5. 5. 5. ] ] ] [ 6.3 0.51 0.13

Add a comment
Know the answer?
Add Answer to:
Description Download 'hw6_numpy_wine.csv' as the source file, each row in the data file is some metrics...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a class named SatData that reads a JSON file containing data on 2010 SAT results...

    Write a class named SatData that reads a JSON file containing data on 2010 SAT results for New York City and writes the data to a text file in CSV (comma-separated values) format. It just needs to read a local JSON file - it doesn't need to access the internet. Specifically, your class should have an init method that reads the file, and it should have a method named save_as_csv that takes as a parameter a list of DBNs (district...

  • + Run C Code IMPORTANT: • Run the following code cell to create the input file,...

    + Run C Code IMPORTANT: • Run the following code cell to create the input file, biostats.csv, which you will be using later. 74, In [ ]: N %%file biostats.csv Name, Sex, Age, Alex, M, 41, Bert, M, 42, Dave, M, 39, Elly, F, 30, Fran, F, 33, Jake, M, F, Luke, M, 34, F Myra, M, M, 38, Ruth, F, 28, 22 22 323 47 47, Height, Weight 170 200 167 70 115 143 139 280 98 75, 350...

  • Reading and parsing a CSV data file in java Note: I.) the first row contains the...

    Reading and parsing a CSV data file in java Note: I.) the first row contains the field definition II.) Columns are separated by comma This is the data.csv file These are the instructions This is my code so far A D F G H J K 1 FirstName LastName DateOfBirth SSN Role Salary Zip Phone 2 Radioactive Man BMockingbird 4Captain Triumph 5 Deathstroke, th Chief garlic 9/29/1912 846330158 Administration 39157 7166875260 69989 persimmon 9/22/1956 835340509 Administration 13884 39157 1421813391 usb...

  • Reading and parsing a CSV data file in java Note: I.) the first row contains the...

    Reading and parsing a CSV data file in java Note: I.) the first row contains the field definition II.) Columns are separated by comma This is the data.csv file These are the instructions This is my code so far A D F G H J K 1 FirstName LastName DateOfBirth SSN Role Salary Zip Phone 2 Radioactive Man BMockingbird 4Captain Triumph 5 Deathstroke, th Chief garlic 9/29/1912 846330158 Administration 39157 7166875260 69989 persimmon 9/22/1956 835340509 Administration 13884 39157 1421813391 usb...

  • Problem 1 (Reading Statistics) Write a function called read_stats(filename) that takes a csv (comma separated values)...

    Problem 1 (Reading Statistics) Write a function called read_stats(filename) that takes a csv (comma separated values) filename as an argument and returns a 2D list containing the statistics in that file. The returned list should contain lists of stats for each crime reported and should not include the header line from the file. The file crime_in_vancouver.csv (included in the folder) has the following structure: • The first row provides headers for each column • Each subsequent row represents the stats...

  • do it in python 1. Import the proper libraries: Pandas and NumPy and create aliases pd,...

    do it in python 1. Import the proper libraries: Pandas and NumPy and create aliases pd, np respectively. 2. Load sample data (car_loan.csv) into data frame: df 3. Export Pandas DataFrames to csv. Save file name as out.csv. hint: help(df.to_csv) 4. Run the command: df.info (). What do you see, how many columns? also what about number of entries for each column 5. It is often the case where you change your column names or remove unnecessary columns. a. Change...

  • I can't attach the data due to the file being real large i can email it...

    I can't attach the data due to the file being real large i can email it to you so i can have your help on it # Assignment 1 # R Programming Language # ---- Why do Exploratory Data Analysis (EDA)? ---- # We will be looking at ## identifying outliers ## null values ## generating plots ## examining correlations # -------------------------------------------------------------- # In this video we will cover: ## univariate plots for continuous variables (boxlots, historgrams) ## bivariate plots...

  • Here are the data needed for the program. SanFrancisco.csv station_id,name,lat,long,dockcount,landmark,installation 41,Clay at Battery,37.795001,-122.39997,15,San Francisco,8/19/2013 42,Davis at Jac...

    Here are the data needed for the program. SanFrancisco.csv station_id,name,lat,long,dockcount,landmark,installation 41,Clay at Battery,37.795001,-122.39997,15,San Francisco,8/19/2013 42,Davis at Jackson,37.79728,-122.398436,15,San Francisco,8/19/2013 45,Commercial at Montgomery,37.794231,-122.402923,15,San Francisco,8/19/2013 46,Washington at Kearney,37.795425,-122.404767,15,San Francisco,8/19/2013 47,Post at Kearney,37.788975,-122.403452,19,San Francisco,8/19/2013 48,Embarcadero at Vallejo,37.799953,-122.398525,15,San Francisco,8/19/2013 49,Spear at Folsom,37.790302,-122.390637,19,San Francisco,8/20/2013 50,Harry Bridges Plaza (Ferry Building),37.795392,-122.394203,23,San Francisco,8/20/2013 SanJose.csv station_id,name,lat,long,dockcount,landmark,installation 2,San Jose Diridon Caltrain Station,37.329732,-121.901782,27,San Jose,8/6/2013 3,San Jose Civic Center,37.330698,-121.888979,15,San Jose,8/5/2013 4,Santa Clara at Almaden,37.333988,-121.894902,11,San Jose,8/6/2013 5,Adobe on Almaden,37.331415,-121.8932,19,San Jose,8/5/2013 6,San Pedro Square,37.336721,-121.894074,15,San Jose,8/7/2013 7,Paseo de San Antonio,37.333798,-121.886943,15,San Jose,8/7/2013 8,San Salvador at 1st,37.330165,-121.885831,15,San Jose,8/5/2013...

  • Reading and parsing a CSV file in Java NOTE: a.) The first row contains the field...

    Reading and parsing a CSV file in Java NOTE: a.) The first row contains the field definition b.) Columns are separated by comma This is the data.csv file These are the coding instructions. Questions 1,2 and 3 This is my code so far FirstName Radioactive Man LastName DateOfBirth SSN Salary Role Zip Phone garlic 9/29/1912 846330158 Administration 69989 39157 7166875260 Mockingbird Captain Triumph Deathstroke, th persimmon 9/22/1956 835340509 Administration 13884 39157 1421813391 usb 7/19/1940 8/8/1970 979204716 Back Office 75710 39157...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT