Appendix A: Generating the Tickets DataFrame

The following Python script is associated with Listing 4-27  in Chapter 4 , “Indexing and GroupBy.”
The tickets DataFrame is generated by calling the numpy randn random number generator to create data values, defines rows and columns, and assigns both the row labels and the column labels with a MultiIndex object . The syntax
index = pd.MultiIndex.from_product([[2015, 2016, 2017, 2018], [1, 2, 3]], names = ['Year', 'Month'])
creates the Python object index by calling the MultiIndex.from_product() constructor to form the MultiIndex structure as the Cartesian product for Year values by Month values. This structure provides row labels for the tickets DataFrame shown in Listing 4-27 . The MultiIndex ...

Get Python for SAS Users: A SAS-Oriented Introduction to Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.