Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overall point: create a special data structure that will be a list of numbers Write a code ( python ) that reads a csv file

Overall point: create a special data structure that will be a list of numbers
Write a code (python) that reads a csv file and can run these codes on it (code below)
Some criteria:
# - read data from disk, and create a list of the calculation lists.
# - process those lists to get actual outputs.
#outputs = processCalculationLists(calculationListLoader("inputs.csv"), output_file="output.csv")
#outputs.head()
Example table of input file contents
Name Type Threshold Value_0 Value_1 Value_2
list_0 stdList 30.1960925065
list_1 stdList 37.8329769355
list_2 meanList 42.901578392
Example table of output file contents (what we tryna do with the code)
Name Length Threshold Value
list_0530.196019
list_1937.832929
list_24542.901542
code currently:
from typing import MutableSequence
from abc import ABC, abstractmethod
import numpy as np
class CalculationList(MutableSequence, ABC):
def __init__(self, data):
self.data = data
@abstractmethod
def prune(self):
pass
def __delitem__(self, index):
del self.data[index]
def __getitem__(self, index):
return self.data[index]
def __len__(self):
return len(self.data)
def __setitem__(self, index, value):
self.data[index]= value
class StdList(CalculationList):
def prune(self):
mean_val = np.mean(self.data)
std_val = np.std(self.data)
threshold = std_val * self.data.threshold
indices_to_remove = np.where(np.abs(self.data - mean_val)> threshold)[0]
self.data = np.delete(self.data, indices_to_remove)
class MeanList(CalculationList):
def prune(self):
mean_val = np.mean(self.data)
threshold = self.data.threshold
indices_to_remove = np.where(np.abs(self.data - mean_val)> threshold)[0]
self.data = np.delete(self.data, indices_to_remove)
class SumList(CalculationList):
def prune(self):
sum_val = np.sum(self.data)
threshold = self.data.threshold
indices_to_remove = np.where(self.data > threshold)[0]
self.data = np.delete(self.data, indices_to_remove)

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

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What are antidiscrimination laws? What protections do they include?

Answered: 1 week ago

Question

Where do you see yourself in 5 years?

Answered: 1 week ago

Question

L A -r- P[N]

Answered: 1 week ago