Urgent need with the python code in time series stocks data

This is my main dataset
stock_final!

Date Open High Low Close Adj Close Volume Name Loss percent
0 2018-01-02 0.145 0.155 0.145 0.151 0.151 498275.0 AAIT NaN
1 2018-01-03 0.153 0.153 0.152 0.153 0.153 211100.0 AAIT 1.324506
2 2018-01-04 0.153 0.153 0.152 0.152 0.152 423186.0 AAIT -0.653596
3 2018-01-08 0.151 0.151 0.150 0.150 0.150 140881.0 AAIT -1.315782
4 2018-01-09 0.152 0.158 0.152 0.153 0.153 2649386.0 AAIT 1.999994

this is my filtered dataset which has details of crash events.
stocks_filtered

index Date Event_index Open High Low Close Adj Close Volume Name
0 0 2018-02-06 1 1489.0 1547.0 711.000000 746.000000 746.000000 987706.0 TVIX
1 1 2018-02-26 2 13.5 13.5 8.100000 8.100000 8.100000 580117.0 ABIO
2 2 2018-03-09 3 62.5 66.5 41.099998 42.400002 42.400002 291200.0 SNSS
3 3 2018-03-29 4 80.0 80.0 50.000000 60.000000 60.000000 237971.0 NVCN
4 4 2018-04-10 5 608.0 608.0 600.000000 608.000000 608.000000 100.0 VRTB

From these two datasets , i created a new dataset where for each crash event I fetched data from main dataset for T-1 to T+30 days data. (T is the day when crash event occured )

code

from datetime import datetime, timedelta
dfList = []
for index, row in stocks_filtered.iterrows():
  tempDF = stock_final[(stock_final['Name'] == row['Name']) & (stock_final['Date'].between(row['Date']-timedelta(days=1), row['Date']+timedelta(days=31)))].reset_index(drop=True)
  dfList.append(tempDF)

for i in range(len(dfList)):
  dfList[i].insert(0,'Event_index',i+1)

dfFinal = pd.concat(dfList, ignore_index=True, axis=0)

My output dataset is like this

I need to fetch exact 31 working days of data for every crash event but for my code it is fetching for 30 days including the weekends. Can anyone help me getting T-1 to T+30 working days data from my first two datasets i.e every crash event will have 31 days of data.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).