CLN: localising scope of functions in `Styler`
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them

`Styler` has a mixture of function placements, e.g. outer scope, or as class methods or inner scope of class methods.

This PR has moved two outer scope functions to inner scope of class methods, where they are only used / relevant for that section, to be more consistent with the rest of the class.

