As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the same place. For this task, you'll implement a class DataFrame that maintains a collection of data items inside self.items, which you keep as a list of floats, and provides the following operations: 1. Upon creation (remember that 2. A class method def add(self, x) will add either x or the members of x to the list self.items. Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added to the list directly. If x is a list or a tuple, its members are individually added to the list. 3. A class method mean(self) will compute and return the mean of the data maintained in the Linit_ function?), the collection is empty. collection.
As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the same place. For this task, you'll implement a class DataFrame that maintains a collection of data items inside self.items, which you keep as a list of floats, and provides the following operations: 1. Upon creation (remember that 2. A class method def add(self, x) will add either x or the members of x to the list self.items. Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added to the list directly. If x is a list or a tuple, its members are individually added to the list. 3. A class method mean(self) will compute and return the mean of the data maintained in the Linit_ function?), the collection is empty. collection.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
100%
Python
![As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the
same place. For this task, you'll implement a class DataFrame that maintains a collection of data items
inside self.items, which you keep as a list of floats, and provides the following operations:
_init__function?), the collection is empty.
1. Upon creation (remember that
2. A class method def add(self, x) will add either x or the members of x to the list self.items.
Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added
to the list directly. If x is a list or a tuple, its members are individually added to the list.
3. A class method mean(self) will compute and return the mean of the data maintained in the
collection.
4. A class method percentile(self, r) will compute and return the value at the r-th percentile
of the data in the collection, where r is an integer in [0, 100) (i.e., excluding 100 but including 0).
For this problem, this is the value at the position [G) es (counting from 0) in the sorted list of
values, where l is the size of the collection. As an example, for the data collection [4,2,8,7,3, 1,5],
the 98-th percentile value is 8 because the collection once sorted is [1,2,3,4,5,7,8] and [() e] =
[0.98 × 7] = 6. You may find the built-in function sorted useful.
5. A class method mode (self) will compute and return the mode of the data. The mode of the
data is the item that appears the most often in the dataset (i.e., has the highest frequency). If
many items have the same highest frequency, your function can return any one of them.
6. A class method sd(self) will compute and return the standard deviation of the data. If the data
100
100
items are xo, X1,..., XN-1, use the formula
N-1
E (xi – x)2,
i=0
where N is the number of data items in your collection and x is the mean of the data.
When these methods are called, it is possible that they are interleaved. For example, call add, followed
by another add, then mean, then a couple more add's. It is, however, guaranteed that the collection will
not be
empty
when
your code is asked to report a statistic.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F48954d8a-c361-4523-b68b-ac12d6ced482%2F2f1ec396-0f50-4469-a5f3-03149eb09105%2Frgv7r1_processed.png&w=3840&q=75)
Transcribed Image Text:As we have seen in lecture, a class provides a means to make code and data live (conceptually) in the
same place. For this task, you'll implement a class DataFrame that maintains a collection of data items
inside self.items, which you keep as a list of floats, and provides the following operations:
_init__function?), the collection is empty.
1. Upon creation (remember that
2. A class method def add(self, x) will add either x or the members of x to the list self.items.
Here x is one of the following: (1) a number, (2) a list, or (3) a tuple. If x is a number, it is added
to the list directly. If x is a list or a tuple, its members are individually added to the list.
3. A class method mean(self) will compute and return the mean of the data maintained in the
collection.
4. A class method percentile(self, r) will compute and return the value at the r-th percentile
of the data in the collection, where r is an integer in [0, 100) (i.e., excluding 100 but including 0).
For this problem, this is the value at the position [G) es (counting from 0) in the sorted list of
values, where l is the size of the collection. As an example, for the data collection [4,2,8,7,3, 1,5],
the 98-th percentile value is 8 because the collection once sorted is [1,2,3,4,5,7,8] and [() e] =
[0.98 × 7] = 6. You may find the built-in function sorted useful.
5. A class method mode (self) will compute and return the mode of the data. The mode of the
data is the item that appears the most often in the dataset (i.e., has the highest frequency). If
many items have the same highest frequency, your function can return any one of them.
6. A class method sd(self) will compute and return the standard deviation of the data. If the data
100
100
items are xo, X1,..., XN-1, use the formula
N-1
E (xi – x)2,
i=0
where N is the number of data items in your collection and x is the mean of the data.
When these methods are called, it is possible that they are interleaved. For example, call add, followed
by another add, then mean, then a couple more add's. It is, however, guaranteed that the collection will
not be
empty
when
your code is asked to report a statistic.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY