Generating code
In this section, we are going to make use of codegenerator.py to generate the base classes and its corresponding subclasses, which maintain and print various catalogs for the ABC Car Agency, as follows:
- To begin with, let’s start using the automobile data to generate the base classes required for this application. For the base data preparation, let’s import the
pandaslibrary, which helps with processing data:import pandas as pd
- Let’s load the data and make a copy of it. For this application, we need a unique set of car brands and another unique set of car body styles:
auto = pd.read_csv("automobile.csv") auto_truncated = auto.copy(deep=True) auto_truncated.drop_duplicates(subset = ['make','body-style'], inplace = True) auto_truncated.reset_index(inplace = True, drop = True) auto_truncated['make'] = auto_truncated['make'].apply(lambda x: x.title().replace('-',''))...