qis.np_array_to_df_columns

qis.np_array_to_df_columns(a, ncols)[source]

broadcast a 1-d array down the columns of a frame-shaped array.

For applying a per-date vector across every asset: the array of length len(df.index) is tiled into shape (len(a), ncols), so it can multiply or divide a panel elementwise without relying on pandas alignment.

Parameters:
  • a (ndarray) – values, one per row of the target frame

  • ncols (int) – number of columns to broadcast across

Returns:

an array of shape (len(a), ncols) with a repeated in every column

Return type:

ndarray