learn_sphinx_doc’s functions that may be used

You can use the useful functions from learn_sphinx_doc.utils module to make your life easier:

learn_sphinx_doc.utils.apply_scaling(df: pandas.core.frame.DataFrame, method: Optional[Union[str, Callable]] = 'MinMax', kwargs: Dict = {})[source]

Utility function to be used in conjunction with pandas pipe() to scale columns of a data frame seperately.

Parameters
df: pd.DataFrame

The data frame you want to scale.

method: Callable, str

The name of the method you wish to use [method options: “MinMax”, “Standard”], or an Sklearn transformer, see: https://scikit-learn.org/stable/modules/preprocessing.html

kwargs: Dict

Dictionary containing additional keywords to be added to the Scaler.

Returns
pd.DataFrame

Examples

>>> import seaborn as sns
>>> import pandas as pd
>>> df = sns.load_dataset("iris")
>>> scaled_df = (df
...             .select_dtypes("number")
...             .pipe(apply_scaling)
...             )
learn_sphinx_doc.utils.flatten(list_of_lists)[source]

Utility function used to flatten a list of list into a single list.

Parameters
l: list

A list of lists.

Returns
pd.DataFrame

Examples

>>> from jmspack.utils import flatten
>>> list_of_lists = [[f"p_{x}" for x in range(10)],
...                 [f"p_{x}" for x in range(10, 20)],
...                 [f"p_{x}" for x in range(20, 30)]]
>>> flatten(list_of_lists)
class learn_sphinx_doc.utils.JmsColors[source]

Utility class for James Twose’s color codes.

Parameters
  • get_names() – returns a list of the color names e.g. [PURPLE, DARKBLUE, etc.]

  • to_dict() – returns a dictionary of format {color name: hexcode}

  • to_list() – returns a list of hexcodes

  • plot_colors() – returns a lineplot of all the available colours (like a color swatch)

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from jmspack.utils import JmsColors
>>> x = np.linspace(0, 10, 100)
>>> fig = plt.figure()
>>> _ = plt.plot(x, np.sin(x), color=JmsColors.ORANGE)
>>> _ = plt.plot(x, np.cos(x), color=JmsColors.LIGHTBLUE)
>>> # plt.show()
BLUEGREEN = '#009cdc'
DARKBLUE = '#0072e8'
DARKGREY = '#282d32'
GREENBLUE = '#00c7b1'
GREENYELLOW = '#71db5c'
LIGHTGREY = '#b1b1b1'
MEDIUMGREY = '#808080'
OFFWHITE = '#d5d5d5'
PURPLE = '#8f0fd4'
YELLOW = '#fcdd14'
static get_names()[source]
static plot_colors()[source]
static to_dict()[source]
static to_list()[source]
learn_sphinx_doc.utils.silence_stdout()[source]

Utility function used to suppress print statements from other functions.

Parameters
None
Returns
None

Examples

>>> message = "Ooo look"
>>> with silence_stdout():
...    print(f"My super cool message: {message}")   
>>> print(message)