我正在从这个webpage中读取一个表,其中包含多个Html表,在成功读取它们之后,我想重新生成它们。我已经尝试了许多选项,但我没有工作,加上响应是多索引的,并且几乎尝试了df.rename等所有方法。 我在下面添加代码和响应,有人能帮忙吗
代码:
import uuid
import pandas as pd
class traffic():
def __init__(self):
ssl._create_default_https_context = ssl._create_unverified_context
global homePage
global downloadDir
global filname
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
downloadDir = "C:\\Users\\user\\PycharmProjects\\digitalOcean\\venv\\testDara\\"
uFileName = str(uuid.uuid4())
filname = downloadDir + uFileName + ".csv"
dailyUrl = "https://www.nratrafficdata.ie/c2/tfhourdirection.asp?sgid=ZvyVmXU8jBt9PJE$c7UXt6&spid=NRA_000000001081&reportdate=2018-12-01&enddate=2018-12-01"
iDf = pd.read_html(dailyUrl, index_col=False)
df = iDf[0]
#dff = df.rename({'1':'one', '2':'two'}, axis='columns', inplace=True)
print(df)
if __name__ == '__main__':
objCall = traffic()```
Example response:
check this [1]: https://pasteboard.co/HXPrTVw.png "response"
用这个来解决它,
df.columns = ['ccc','dd','cccs','dd','ddd', 'dddd']
相关问题 更多 >
编程相关推荐