My code is as follows,
sid = ["592009","478299","621403","112501","250217","1000060","1002776"]
sids = pd.DataFrame()
for i in sid:
r = requests.get(f"https://frapi.marketsmojo.com/stocks_quality/cardinfo?sid={i}")
js = r.json()["data"]["quality_tbl"]["list"]
ratios = pd.DataFrame.from_dict(js)
#ratios.columns = ratios.columns[1]
sids= sids.append(ratios)
Here I am looping through list of company with number of sid_id, I need to create a dataframe, from the list of sid_ID present.
Sample of the output is as follows,
| name | value |
|---|---|
| Net Interest Income Growth (5y) | 18.80% |
| Net Profit Growth (5y) | 20.55% |
| Advance to Deposit | 86.55% |
| Capital Adequacy Ratio (Tier 1) | 15.58% |
| Gross NPA (latest) | 0.81% |
| Gross NPA (avg) | 1.19% |
| Coverage Ratio (avg) | 72.27% |
| Cost to Income (avg) | 40.16% |
| Net Interest Margin (avg) | 4.54% |
| Operating Profit to Assets (avg) | 5.98% |
| ROA (avg) | 1.75% |
This output is from 1 iteration of loop. How to get the output for all iteration as.
| name | C1 | C2 | C3 |
|---|---|---|---|
| Net Interest Income Growth (5y) | 18.80% | 19.80% | 18.80% |
| Net Profit Growth (5y) | 20.55% | 20.1% | 23.8% |
| Advance to Deposit | 86.55% | 20.1% | 23.8% |
| Capital Adequacy Ratio (Tier 1) | 15.58% | 20.1% | 23.8% |
| Gross NPA (latest) | 0.81% | 20.1% | 23.8% |
| Gross NPA (avg) | 1.19% | 20.1% | 23.8% |
| Coverage Ratio (avg) | 72.27% | 20.1% | 23.8% |
| Cost to Income (avg) | 40.16% | 20.1% | 23.8% |
| Net Interest Margin (avg) | 4.54% | 20.1% | 23.8% |
| Operating Profit to Assets (avg) | 5.98% | 20.1% | 23.8% |
| ROA (avg) | 1.75% | 20.1% | 23.8% |
how to change the for loop to get the desired output. Or use list and get it is as dataframe?
Any suggestions?