Calculate calender spread payoff

I want to calculate calender spread payoff

Probelm:

But i want to import the data from nsepy instead of manually giving the input for each calculation.

can anyone help how to import data of different expiry and use the same to calculate calender spread payoff

You can find the notebooks to fetch data from nsepy from the Downloadable Resources (Section 7 Unit 2). Thanks!