# 資料擷取與匯入 - CSV
#CSV檔放在jupyter files路徑下 (同一層)
import pandas as pd
df1=pd.read_csv("2012MLB.csv",encoding="big5")
df1
#參考http://ithelp.ithome.com.tw/articles/10185922
df1.describe() # dataframe的描述統計
df1.dtypes #查看欄位屬性
df1.head()
#網路爬蟲 -爬運動新聞
import requests
import pandas as pd
from bs4 import BeautifulSoup
res=requests.get("http://sports.ltn.com.tw/baseball")
soup122=BeautifulSoup(res.text,'html.parser') #將HTML剖析 至變數soup122
xx=pd.Series()
for i in soup122.select("div[class='list_title']"):
xx=xx.append(pd.Series([i.text])).reset_index(drop=True)
xx
文章標籤
全站熱搜
