iT邦幫忙

1

Day15 參加職訓(機器學習與資料分析工程師培訓班),Python程式設計

今天教seaborn真的覺得比matplotlib厲害好多,也教了Requests跟bs4

import seaborn as sns
sns.set_theme()
tip = sns.load_dataset('tips')
Tip_plot = sns.FacetGrid(tip, col = 'time', row = 'sex')
Tip_plot.map(sns.scatterplot, 'total_bill', 'tip')

https://ithelp.ithome.com.tw/upload/images/20210720/20139039d7lsCBxWwx.png

sns.set_theme()
tip = sns.load_dataset('tips')
Tip_plot = sns.FacetGrid(tip, col = 'time', hue = 'sex')
Tip_plot.map_dataframe(sns.scatterplot, x = 'total_bill', y = 'tip')
Tip_plot.set_axis_labels('Total bill', 'Tip')
Tip_plot.add_legend()

https://ithelp.ithome.com.tw/upload/images/20210720/20139039KTCtXuwqmk.png

sns.relplot(data = tip, x = 'total_bill', y = 'tip', hue = 'day', style = 'day', size = 'size')

https://ithelp.ithome.com.tw/upload/images/20210720/20139039rcLsvv4Ntr.png

fmri = sns.load_dataset('fmri')
fmri.head()
sns.relplot(data = fmri, x = 'timepoint', y = 'signal', col = 'region', hue = 'event', kind = 'line')

https://ithelp.ithome.com.tw/upload/images/20210720/20139039hyPFbAwsbZ.png

sns.set_theme()
penguins = sns.load_dataset('penguins')
sns.pairplot(data = penguins)

https://ithelp.ithome.com.tw/upload/images/20210720/20139039AvM3s187CB.png

#爬今彩539號碼
from bs4 import BeautifulSoup
import requests 
lottery = requests.get('https://www.taiwanlottery.com.tw')
lottery_BS = BeautifulSoup(lottery.text, 'lxml')

Selected01 = lottery_BS.select('#rightdown')
Selected02 = Selected01[0].find('div', {'class': 'contents_box03'})
Selected03 = Selected02.find_all('div', {'class': 'ball_tx'})

print('開出順序', end= ' ')
for i in range(0,6):
    print(Selected03[i].text, end= ' ')
print('大小排序', end= ' ')
for i in range(6,11):
    print(Selected03[i].text, end= ' ')

尚未有邦友留言

立即登入留言