這裡提供作法讓千分位再顯示回來,如下程式碼。
import requests
import pandas as pd
from bs4 import BeautifulSoup as bs
url = "http://www.twse.com.tw/fund/BFI82U?response=html&type=day"
tb = bs(requests.get(url).text, "lxml").select("table")[0]
df = pd.read_html(tb.prettify(), encoding= 'utf8', skiprows=[0], header=0)[0].iloc[0:5]
df.iloc[:,1:] = df.iloc[:,1:].apply(lambda x : x.astype(int).apply('{:,}'.format))
df
加入以下這行程式即可解決。
df.iloc[:,1:] = df.iloc[:,1:].apply(lambda x : x.astype(int).apply('{:,}'.format))


沒有留言:
張貼留言