4.4 Calculating Statistics on Data
In the next few sections, we analyze data sets using simple statistics and assume that our data is stored in list structures. For example, let’s assume that we want to analyze statistics on earthquakes worldwide. During one seven-day period, we find that there were 37 earthquakes on Monday, 32 on Tuesday, 46 on Wednesday, 28 on Thursday, 37 on Friday, 41 on Saturday, and 31 on Sunday. This data can be stored in the simple list [37, 32, 46, 28, 37, 41, 31]
.
Python’s statistics
module can help with our analysis of the data. TABLE 4.5 highlights some useful functions from this module . To use these methods, we need to import
the statistics
module. In addition, we can get help from some built-in functions, as ...
Get Python Programming in Context, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.