import pandas as pd
import requests
from bs4 import BeautifulSoup
# A function that makes the event code pretty
def make_code(x):
x = str(x)
x = x.zfill(6)
return x
# Obtaining the event code
url_comp_code = "http://kind.krx.co.kr/corpgeneral/corpList.do?method=download&searchType=13&marketType=%s"
code_data = pd.read_html(url_comp_code, header=0)[0]
code_data = code_data ["stock code", "company name"]
code_data["stock code"] = code_data["stock code"].apply(make_code)
# Apply item code to url
for num, code in enumerate (code_data["entry code")):
fs_url = "http://comp.fnguide.com/SVO2/ASP/SVD_Main.asp?pGB=1&gicode=A{}&cID=&MenuYn=Y&ReportGB=&NewMenuID=101&stkGb=701".format(code)
fs_page = requests.get(fs_url)
soup = pd.read_html(fs_page.text, "lxml")
table = soup.find_all("table")
df_{code} = pd.read_html(str(table))
# Zero NaN value for table
for i in range(len(df_{code})):
df[i].fillna(0,inplace=True)
print(df_{code}[0])
I'm getting an error, I think it's because I set it like df_{code} = pd.read_html(str(table))
Can't I specify a variable like this?
I'd appreciate it if you could answer me.
Please give me a solution, too.
python
df_{code} = pd.read_html(str(table))
I think it's because you set it like this, but can't I specify a variable like this?
I can't.
574 Uncaught (inpromise) Error on Electron: An object could not be cloned
561 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
583 GDB gets version error when attempting to debug with the Presense SDK (IDE)
832 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.