I am using nsepython library for data extraction. I was extracting lot size for particular symbol from function nse_get_fno_lot_sizes of nsepython library.
I want the output of function nse_get_fno_lot_sizes in dataframe format instead of current format.
Complete Code - https://github.com/aeron7/nsepython/blob/master/nsepython/rahu.py
nse_get_fno_lot_sizes function-
def nse_get_fno_lot_sizes(symbol="all",mode="list"):
url="https://archives.nseindia.com/content/fo/fo_mktlots.csv"
if(mode=="list"):
s=requests.get(url).text
res_dict = {}
for line in s.split('\n'):
if line != '' and re.search(',', line) and (line.casefold().find('symbol') == -1):
(code, name) = [x.strip() for x in line.split(',')[1:3]]
res_dict[code] = int(name)
if(symbol=="all"):
return res_dict
if(symbol!=""):
return res_dict[symbol.upper()]
if(mode=="pandas"):
payload = pd.read_csv(url)
if(symbol=="all"):
return payload
else:
payload = payload[(payload.iloc[:, 1] == symbol.upper())]
return payload
My Code-
print(nse_get_fno_lot_sizes("adaniports","pandas"))
print(type(nse_get_fno_lot_sizes))
Output-
UNDERLYING SYMBOL JUL-22 AUG-22 SEP-22 DEC-22 MAR-23 JUN-23 DEC-23 JUN-24 DEC-24 JUN-25 DEC-25 JUN-26 DEC-26 JUN-27
8 ADANI PORT & SEZ LTD ADANIPORTS 1250 1250 1250
<class 'function'>
I want to convert the output getting from the nse_get_fno_lot_sizes function as dataframe.
Documentation- https://aeron7.github.io/nsepython/documentation/nsetools.html#top-losers-gainers