Home > Back-end >  convert a list of dataframe into another dataframe
convert a list of dataframe into another dataframe

Time:08-14

Code:

from datetime import date
from datetime import timedelta
from nsepy import get_history
import pandas as pd


end1 = date.today()
start1 = end1 - timedelta(days=25)
exp_date1 = date(2022,8,25)
exp_date2 = date(2022,9,29)

# stock = ['HDFCLIFE']
stock = ['RELIANCE','HDFCBANK','INFY','ICICIBANK','HDFC','TCS','KOTAKBANK','LT','SBIN','HINDUNILVR','AXISBANK',
         'ITC','BAJFINANCE','BHARTIARTL','ASIANPAINT','HCLTECH','MARUTI','TITAN','BAJAJFINSV','TATAMOTORS',
         'TECHM','SUNPHARMA','TATASTEEL','M&M','WIPRO','ULTRACEMCO','POWERGRID','HINDALCO','NTPC','NESTLEIND',
         'GRASIM','ONGC','JSWSTEEL','HDFCLIFE','INDUSINDBK','SBILIFE','DRREDDY','ADANIPORTS','DIVISLAB','CIPLA',
         'BAJAJ-AUTO','TATACONSUM','UPL','BRITANNIA','BPCL','EICHERMOT','HEROMOTOCO','COALINDIA','SHREECEM','IOC']

target_stocks = []
# oi_change = []
for stock in stock:
    stock_jan = get_history(symbol=stock,
                        start=start1,
                        end=end1,
                        futures=True,
                        expiry_date=exp_date1)
    stock_feb = get_history(symbol=stock,
                        start=start1,
                        end=end1,
                        futures=True,
                        expiry_date=exp_date2)
    delivery_per_age = get_history(symbol=stock,
                               start=start1,
                               end=end1)
    symbol_s = get_history(symbol=stock,
                       start=start1,
                       end=end1)
    oi_combined = pd.concat([stock_jan['Change in OI']   stock_feb['Change in OI']])
    total_oi = pd.concat([stock_jan['Open Interest'] stock_feb['Open Interest']])
    delivery_vol = pd.concat([delivery_per_age['Deliverable Volume']])
    # delivery_per = pd.concat([delivery_per_age['           
  • Related