quantlab.model.collected_panel.to_array#
- quantlab.model.collected_panel.to_array(data, variables, dtype=None)[source]#
Convert a panel to a
[num_times, num_symbols, len(variables)]array.Both axes are sorted, and the last axis follows the order of
variablesexactly (not alphabetical order), sox[..., i]is alwaysvariables[i].- Parameters:
- dataxr.Dataset
A dataset indexed by
(timestamp, symbol).- variableslist[str]
The data variables to stack, in the wanted order.
- dtypenumpy dtype, optional
The array’s type; by default the variables’ common type.
- Returns:
- np.ndarray
The stacked variables.
Examples
>>> to_array(panel, ["f_b", "f_a"]).shape (40, 3, 2) >>> to_array(panel, ["f_b", "f_a"], dtype=np.float32).dtype dtype('float32')