INNER CODE UNIT · Python
_create_unicode_hist
aeturrell/skimpy · src/skimpy/__init__.py:319
def _create_unicode_hist(series: pd.Series) -> pd.Series:
"""Return a histogram rendered in block unicode.
Given a pandas series of numerical values, returns a series with one
entry, the original series name, and a histogram made up of unicode
characters. However, note that the histogram is very approximate, partly
due to limitations in how unicode is displayed across systems.
Args:
series (pd.Series): Numeric column of data frame for analysis
Returns:
pd.Series: Index of series name and entry with unicode histogram as
a string, eg '▃▅█'
"""
if series.dtype == "bool":
series = series.astype("int")
hist, _ = np.histogram(series, density=True, bins=HIST_BINS)