Join blocks of returns end to end with np.concatenate, and pair every ticker with every date of a long panel with np.repeat and np.tile.
After this lesson, you can join blocks of returns in order and build a long panel with one row per ticker and date.
How do I join two weeks of returns?
np.concatenate([first_week, second_week]) joins two arrays end to end, in the order of the list, so ten daily returns stay ten returns in date order. + does that for lists, while on two arrays it adds the returns at the same positions, so the first of five values is 0.012 + 0.015, two different Mondays added.
The returns are a made-up stock’s daily returns in decimals over two weeks. NumPy sees only the values, so the blocks need to be in date order without overlap before the join.
Collecting daily blocks in a list and joining them once copies each value once, while np.append in a loop copies everything gathered so far on every pass.
How do I give every ticker one row per date?
np.repeat(tickers, 3) repeats each ticker three times in a row, and np.tile(dates, 2) repeats the whole list of dates for each ticker, so together they give one row for each ticker and date, a long panel as in the lesson on long and wide panels.
pd.bdate_range("2026-03-02", periods=3) gives three weekdays. Repeating the dates as well would give one ticker the same date twice and miss another date, which .duplicated(["ticker", "date"]).sum() counts.
The following box builds the panel the right way and the wrong way.