INNER CODE UNIT · Python
_round_series
aeturrell/skimpy · src/skimpy/__init__.py:120
def _round_series(s: pd.Series, places: int = 2) -> pd.Series:
"""Rounds numerical series to places number of significant figures
Args:
s (pd.Series): Input series
places (int, optional): Number of significant figures to round to. Defaults to 2.
Returns:
pd.Series: Series with numbers rounded to places s.f.
"""
s = s.apply(lambda x: float(f"{float(f'{x:.{places}g}'):g}"))
return s
@typechecked
def _map_row_positions_to_text_style(types_to_property: dict, df: pd.DataFrame) -> dict:
"""Maps positions in summary dataframe (eg row) to a Rich text property.