Jupyter Notebook Refactoring Series — Part 2

Original article was published on Artificial Intelligence on Medium

Step 2: Produce visuals with ease

EDA (Exploratory Data Analysis) usually contains a lot of visuals. Often I see a lot of redundant code to produce the same type of plots again and again.

For example, you want to plot relationships between categorical values and the predicted median target.

Instead of doing this in Python:

Follow the DRY principle (Don’t Repeat Yourself), and define a function, and use type hints:

What if you want to change the target column? A better option will be: