1 Series

 

If you have any experience with pandas, then you know that we typically work with data in two-dimensional tables, known as "data frames," with rows and columns. But each column in a data frame is built from a "series," a one-dimensional data structure, which means that you can think of a data frame as a collection of series. This perspective is particularly useful once you learn what methods are available on a series, because most of those methods are also available on data frames—only instead of getting a single result, we’ll get one result for each column in the data frame. For example, the mean method, when applied to a series, returns the mean of the values in the series. If you invoke mean on a data frame, then pandas will invoke the mean method on each column, returning a collection of mean values. Moreover, those values are themselves returned as a series, on which you can invoke further methods.

Deep understanding of series can be useful in other ways, too: Series are often used to retrieve selected elements of another series, or even of an entire data frame, using the "boolean index" or "mask index" functionality that’s commonly used in pandas. Given how often we want to retrieve specific parts of a data frame, knowing how best to use this functionality is important.

1.1 Useful references

 
 
 

1.2 Exercise 1: Test scores

 
 

1.2.1 Solution

 

1.2.2 Discussion

 
 
 

1.2.3 Beyond the exercise

 
 

1.3 Exercise 2: Scaling test scores

 
 
 

1.3.1 Solution

 
 
 
 

1.3.2 Discussion

 
 

1.3.3 Beyond the exercise

 
 
 
 

1.4 Exercise 3: Counting 10s digits

 
 

1.4.1 Solution

 
 

1.4.2 Discussion

 
 

1.4.3 Beyond the exercise

 
 
 
 

1.5 Exercise 4: Descriptive statistics

 

1.5.1 Solution

 
 
 

1.5.2 Discussion

 

1.5.3 Beyond the exercise

 
 
 

1.6 Exercise 5: Monday temperatures

 
 
 

1.6.1 Solution

 
 

1.6.2 Discussion

 
 
 

1.6.3 Beyond the exercise

 
 

1.7 Exercise 6: Passenger frequency

 
 

1.7.1 Solution

 

1.7.2 Discussion

 
 

1.7.3 Beyond the exercise

 

1.8 Exercise 7: Long, medium, and short taxi rides

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest