from_pandas#

Free helper: converts a pandas Series or DataFrame to the screamer (values, index) tuple convention. The pandas data becomes the values array and the pandas index becomes the index array.

Examples#

Usage example#

import pandas as pd
from screamer import from_pandas

ser = pd.Series([1.0, 2.0, 3.0], index=[100, 200, 300])
values, index = from_pandas(ser)
print("values:", values)
print("index: ", index)
values: [1. 2. 3.]
index:  [100 200 300]

Signature#

from_pandas(obj, layout=None)

  • obj - a pandas.Series or pandas.DataFrame.

  • layout - optional layout string naming the axes of the values as read. The default None returns obj.to_numpy() with the frame's own dtype and columns, so two-level columns stay flat. A layout reads the values as float64 and reshapes them like reshape: "TA" for one column per asset, or "TAF" for a DataFrame whose two-level columns hold every (asset, field) pair, which gives (T, A, F) values.

Returns (values, index) where both are NumPy arrays.

See also#

  • to_pandas: Convert a (values, index) tuple to a pandas Series or DataFrame

  • Resample: Causal windowed downsample of a 1-D or multi-column value stream

  • CombineLatest: As-of latest-value join of N streams: one row per distinct index (same-index events coalesce)