NSE India API Live Analysis Variations Index Gainers in Python

NSE India API Live Analysis Variations Index Gainers in Python


Follow the Instructions from the Video then go for the Code Input:

  
import json
import pandas as pd  

with open('gain.json','r') as f:
    data=json.load(f)
    
categories=['NIFTY', 'BANKNIFTY','NIFTYNEXT50','SecGtr20','SecLwr20','FOSec','allSec']

df=pd.concat([pd.DataFrame(data[cat]['data'])[['symbol','ltp']] for cat in categories if cat in data])
df_sorted=df.sort_values('ltp').reset_index(drop=True)
print(df_sorted.to_string(index=False))