Explanation: Box 1: pandas as df Pandas takes data (like a CSV or TSV file, or a SQL database) and creates a Python object with rows and columns called data frame that looks very similar to table in a statistical software (think Excel or SPSS for example. Box 2: transpose[ProductCategoryMapping] Reshape the data from the pandas Series to columns. Reference: https://datascienceplus.com/linear-regression-in-python/