finds.utils.utils

Miscellaneous utilities

Copyright 2022, Terence Lim

MIT License

finds.utils.utils.row_formatted(df: DataFrame, formats: Dict = {}, default: str = '{}', width: int = 0) DataFrame[source]

Apply display formats by row index, and set row index width

Parameters:
  • df – DataFrame to format by row

  • formats – Dictionary of format strings, keyed by index label

  • default – Default format string

  • width – To truncate index widths

Examples:

>>> row_formatted(prices, formats={'vwap': '{:.0f}', 'mid': '{:.3f}'})
>>> formats = dict.fromkeys(['start date', 'Num Stocks'], '{:.0f}')
>>> row_formatted(DataFrame(out), formats=formats, default='{:.3f}'))
finds.utils.utils.to_type(v: ~typing.Any, t=<class 'str'>) Any[source]

Convert each element in nested input list to target type