0

hello I have a problem with How to load an array and loop it into dataframe in pandas and i have a code like below :

Tiker = ['one', 'two', 'tree', 'four']
for Tiker in Tiker:
print(Tiker)

Output:
one
two
tree
four

The question is how to enter the array one by one into the link we want

url1 = 'www.data.com/' + Tiker
lm_json = requests.get(url1).json()
df_list=pd.read_html(lm_json["componentData"])
datafin = pd.DataFrame(df_list)

I want to use a loop in the code above and with the end result a separate dataframe from Tiker = ['one', 'two', 'tree', 'four'] from the website that we take the data from

Final Ouput :

dataframe1 = one

dataframe2 = two

dataframe3 = tree

dataframe4 = four

  • Does this answer your question? [How do I create variable variables?](https://stackoverflow.com/questions/1373164/how-do-i-create-variable-variables) – 0x5453 Feb 11 '21 at 16:44
  • does use variables, but the problem is how to use the array for the for loop in the code and pass it into dataframe this a different matter, – Dwijaya Maleh Feb 11 '21 at 16:51
  • `read_html()` for json is unusual, but following does what I believe you are trying to do `pd.concat([pd.read_html(requests.get(f"https://www.data.com/{t}").json()["componentData"]) for t in ["one","two","three"]])` – Rob Raymond Feb 11 '21 at 17:03

0 Answers0