1
pe_scrip = int(df_sort['Heading scrip'].astype(object).iloc[[1]])
gap = 100
start_dt = pd.to_datetime("2021-09-23 09:15:59")
DTE_time = pd.to_timedelta(7, unit='d')
DTE_time
pe_list = [str(pe_scrip),str(pe_scrip+gap),str(pe_scrip),str(pe_scrip-gap),str(pe_scrip)]
pe_list
for list in range(len(pe_list)):
    var = list
    b = []
    for i in range(len(df_sort)):
        find_df = ((df_sort['Heading scrip'].iloc[i] == pe_list[var]) & (df_sort['Option'].iloc[i] == 'PE') 
                    & (df_sort['Date_time'].iloc[i] == start_dt) & (df_sort['DTE'].iloc[i] == DTE_time))
        b.append(find_df)
    #     display([b])
    pe_df = df_sort[b]
    display(pe_df)

enter image description here

I'm using Concat function it doesn't help me, please someone help me where should I use concat function, or how can I concat these all 5 dataframes.

When I using pd.concat - enter image description here

Dataset :
    Ticker  Date    Time    Open    High    Low Close   Volume  Open Interest   Option  Expiry  Symbol  Heading scrip   Date_time   DTE
133561  BANKNIFTY23SEP2136900CE.NFO 2021-09-23  09:15:59    349.95  440.10  349.85  398.60  109250  328725  CE  2021-09-23  BANKNIFTY   36900   2021-09-23 09:15:59 0 days
139190  BANKNIFTY23SEP2137600PE.NFO 2021-09-23  09:15:59    550.00  550.00  225.00  412.45  33900   95850   PE  2021-09-23  BANKNIFTY   37600   2021-09-23 09:15:59 0 days
132813  BANKNIFTY23SEP2136800CE.NFO 2021-09-23  09:15:59    477.95  527.00  462.25  480.55  71450   244000  CE  2021-09-23  BANKNIFTY   36800   2021-09-23 09:15:59 0 days
139942  BANKNIFTY23SEP2137700PE.NFO 2021-09-23  09:15:59    350.00  517.95  350.00  500.35  16750   86675   PE  2021-09-23  BANKNIFTY   37700   2021-09-23 09:15:59 0 days
132099  BANKNIFTY23SEP2136700CE.NFO 2021-09-23  09:15:59    560.05  614.35  551.00  572.00  15425   93075   CE  2021-09-23  BANKNIFTY   36700   2021-09-23 09:15:59 0 days
140693  BANKNIFTY23SEP2137800PE.NFO 2021-09-23  09:15:59    578.95  612.00  545.95  590.70  3575    87050   PE  2021-09-23  BANKNIFTY   37800   2021-09-23 09:15:59 0 days
131425  BANKNIFTY23SEP2136600CE.NFO 2021-09-23  09:15:59    653.00  709.60  644.15  659.00  10700   70300   CE  2021-09-23  BANKNIFTY   36600   2021-09-23 09:15:59 0 days
141444  BANKNIFTY23SEP2137900PE.NFO 2021-09-23  09:15:59    709.90  709.90  625.15  676.10  3975    40100   PE  2021-09-23  BANKNIFTY   37900   2021-09-23 09:15:59 0 days
130686  BANKNIFTY23SEP2136500CE.NFO 2021-09-23  09:15:59    750.95  809.85  737.55  757.10  18525   378825  CE  2021-09-23  BANKNIFTY   36500   2021-09-23 09:15:59 0 days
142194  BANKNIFTY23SEP2138000PE.NFO 2021-09-23  09:15:59    801.00  801.00  730.45  771.30  9650    163850  PE  2021-09-23  BANKNIFTY   38000   2021-09-23 09:15:59 0 days
130165  BANKNIFTY23SEP2136400CE.NFO 2021-09-23  09:15:59    896.00  896.00  837.15  858.05  625 19350   CE  2021-09-23  BANKNIFTY   36400   2021-09-23 09:15:59 0 days
142944  BANKNIFTY23SEP2138100PE.NFO 2021-09-23  09:15:59    889.00  890.05  847.05  874.05  600 34225   PE  2021-09-23  BANKNIFTY   38100   2021-09-23 09:15:59 0 days
129664  BANKNIFTY23SEP2136300CE.NFO 2021-09-23  09:15:59    965.05  965.05  933.90  962.65  625 17325   CE  2021-09-23  BANKNIFTY   36300   2021-09-23 09:15:59 0 days
143690  BANKNIFTY23SEP2138200PE.NFO 2021-09-23  09:15:59    943.25  973.90  943.25  972.45  325 29625   PE  2021-09-23  BANKNIFTY   38200   2021-09-23 09:15:59 0 days
129214  BANKNIFTY23SEP2136200CE.NFO 2021-09-23  09:15:59    1124.25 1124.25 1124.25 1124.25 25  6000    CE  2021-09-23  BANKNIFTY   36200   2021-09-23 09:15:59 0 days
128779  BANKNIFTY23SEP2136100CE.NFO 2021-09-23  09:15:59    1176.30 1176.30 1176.30 1176.30 25  4625    CE  2021-09-23  BANKNIFTY   36100   2021-09-23 09:15:59 0 days
128153  BANKNIFTY23SEP2136000CE.NFO 2021-09-23  09:15:59    1281.85 1281.85 1231.70 1253.65 2075    52025   CE  2021-09-23  BANKNIFTY   36000   2021-09-23 09:15:59 0 days
145792  BANKNIFTY23SEP2138500PE.NFO 2021-09-23  09:15:59    1262.10 1262.15 1262.10 1262.15 150 31600   PE  2021-09-23  BANKNIFTY   38500   2021-09-23 09:15:59 0 days
126104  BANKNIFTY23SEP2135500CE.NFO 2021-09-23  09:15:59    1752.55 1753.50 1752.45 1752.45 75  8825    CE  2021-09-23  BANKNIFTY   35500   2021-09-23 09:15:59 0 days
139191  BANKNIFTY23SEP2137600PE.NFO 2021-09-23  09:16:59    409.00  409.00  372.95  380.65  30375   95850   PE  2021-09-23  BANKNIFTY   37600   2021-09-23 09:16:59 0 days
  • How does the `concat` function not work for you? Can you provide a minimal example? – mozway Oct 04 '21 at 14:25
  • What do you mean by "I'm using Concat function it doesn't help me"? _What_ have you tried, what were your results, and what is wrong with your attempts? Please [edit] to include a [mcve] with sample data (as text, not as an image or link), code, current output, and expected output – G. Anderson Oct 04 '21 at 14:25
  • If i'm using pd.concat(df_sort[b]) i'm getting error - "first argument must be an iterable of pandas objects, you passed an object of type "DataFrame" – krishna gupta Oct 04 '21 at 14:28
  • @krishnagupta please read [this](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) and try to reformat your question according to these guidelines, it is almost impossible to help you otherwise – mozway Oct 04 '21 at 14:29
  • @G.Anderson actually I can't give sample data it's a very big dataset. but I can send screen shot of that. – krishna gupta Oct 04 '21 at 14:46
  • @krishnagupta screnshots are not useful, what is useful is to have a minimal dataset and a minimal code sufficient to reproduce the problem – mozway Oct 04 '21 at 14:47
  • See [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – G. Anderson Oct 04 '21 at 15:14

0 Answers0