97色伦色在线综合视频,无玛专区,18videosex性欧美黑色,日韩黄色电影免费在线观看,国产精品伦理一区二区三区,在线视频欧美日韩,亚洲欧美在线中文字幕不卡

廣州建站公司模板網(wǎng)站備案難嗎

鶴壁市浩天電氣有限公司 2026/01/24 07:01:44
廣州建站公司模板,網(wǎng)站備案難嗎,做公司自主網(wǎng)站,設(shè)計(jì)上海展會(huì)2021時(shí)間一、前言 QS世界大學(xué)排名是全球最具影響力的大學(xué)排名之一#xff0c;無(wú)論是留學(xué)選校、學(xué)術(shù)研究還是高校競(jìng)爭(zhēng)力分析#xff0c;都有重要參考價(jià)值。本文將手把手教你用Python完成QS排名的數(shù)據(jù)爬取、清洗、分析與可視化#xff0c;從0到1實(shí)現(xiàn)完整的數(shù)據(jù)分析流程#xff0c;即使…一、前言QS世界大學(xué)排名是全球最具影響力的大學(xué)排名之一無(wú)論是留學(xué)選校、學(xué)術(shù)研究還是高校競(jìng)爭(zhēng)力分析都有重要參考價(jià)值。本文將手把手教你用Python完成QS排名的數(shù)據(jù)爬取、清洗、分析與可視化從0到1實(shí)現(xiàn)完整的數(shù)據(jù)分析流程即使是Python新手也能輕松上手。分析目標(biāo)爬取2025年QS世界大學(xué)排名核心數(shù)據(jù)排名、學(xué)校名稱、國(guó)家/地區(qū)、總分等清洗數(shù)據(jù)處理缺失值、異常值分析核心維度TOP50高校國(guó)家分布、不同國(guó)家TOP100數(shù)量、總分分布等用可視化圖表直觀展示分析結(jié)果。二、環(huán)境準(zhǔn)備首先安裝所需Python庫(kù)打開(kāi)終端執(zhí)行pipinstallrequests beautifulsoup4 pandas matplotlib lxmlrequests發(fā)送HTTP請(qǐng)求爬取網(wǎng)頁(yè)數(shù)據(jù)beautifulsoup4解析HTML頁(yè)面提取目標(biāo)數(shù)據(jù)pandas數(shù)據(jù)清洗與分析matplotlib數(shù)據(jù)可視化lxml高效的HTML解析器。三、數(shù)據(jù)爬取本文選擇爬取QS官網(wǎng)2025年世界大學(xué)綜合排名公開(kāi)可訪問(wèn)頁(yè)面核心思路發(fā)送請(qǐng)求→解析頁(yè)面→提取字段→存儲(chǔ)為DataFrame。完整爬取代碼importrequestsfrombs4importBeautifulSoupimportpandasaspdimporttime# 配置請(qǐng)求頭模擬瀏覽器訪問(wèn)避免反爬headers{User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36,Accept-Language:zh-CN,zh;q0.9,en;q0.8}# 存儲(chǔ)所有數(shù)據(jù)的列表qs_data[]# QS2025排名頁(yè)面分頁(yè)爬取這里爬取前100名可按需擴(kuò)展base_urlhttps://www.topuniversities.com/rankings/qs-world-university-rankings/2025?page{}# 爬取前10頁(yè)每頁(yè)10條共100條forpageinrange(1,11):try:# 發(fā)送請(qǐng)求urlbase_url.format(page)responserequests.get(url,headersheaders,timeout10)response.raise_for_status()# 拋出HTTP錯(cuò)誤soupBeautifulSoup(response.text,lxml)# 解析頁(yè)面# 定位排名數(shù)據(jù)行rank_rowssoup.find_all(div,class_row indx)forrowinrank_rows:# 提取排名處理并列排名如10rank_elemrow.find(div,class_rank)rankrank_elem.get_text(stripTrue)ifrank_elemelseNone# 提取學(xué)校名稱name_elemrow.find(div,class_uni-name)universityname_elem.get_text(stripTrue)ifname_elemelseNone# 提取國(guó)家/地區(qū)country_elemrow.find(div,class_location)countrycountry_elem.get_text(stripTrue)ifcountry_elemelseNone# 提取總分score_elemrow.find(div,class_overall-score-span)scorescore_elem.get_text(stripTrue)ifscore_elemelseNone# 存儲(chǔ)數(shù)據(jù)qs_data.append({排名:rank,學(xué)校名稱:university,國(guó)家/地區(qū):country,總分:score})print(f第{page}頁(yè)數(shù)據(jù)爬取完成已獲取{len(qs_data)}條記錄)time.sleep(1)# 延遲1秒避免請(qǐng)求過(guò)快被封IPexceptExceptionase:print(f第{page}頁(yè)爬取失敗{str(e)})continue# 轉(zhuǎn)換為DataFramedfpd.DataFrame(qs_data)# 保存原始數(shù)據(jù)到CSV可選df.to_csv(qs2025_rank_raw.csv,indexFalse,encodingutf-8-sig)print(原始數(shù)據(jù)爬取完成已保存為qs2025_rank_raw.csv)print(原始數(shù)據(jù)前5行)print(df.head())爬取說(shuō)明若爬取失敗可檢查User-Agent是否為最新替換為自己瀏覽器的UAQS官網(wǎng)頁(yè)面結(jié)構(gòu)可能微調(diào)需根據(jù)實(shí)際HTML結(jié)構(gòu)修改class名稱爬取更多數(shù)據(jù)可修改分頁(yè)范圍如range(1, 51)爬取前500名。四、數(shù)據(jù)清洗爬取的原始數(shù)據(jù)可能存在缺失值、格式異常如總分是字符串、排名含“”需清洗后才能分析。清洗代碼# 加載原始數(shù)據(jù)若已爬取可直接加載dfpd.read_csv(qs2025_rank_raw.csv,encodingutf-8-sig)# 1. 處理缺失值刪除關(guān)鍵字段缺失的行dfdf.dropna(subset[排名,學(xué)校名稱,國(guó)家/地區(qū),總分])print(f刪除缺失值后剩余數(shù)據(jù)量{len(df)})# 2. 清洗排名字段去除“”轉(zhuǎn)換為整數(shù)df[排名]df[排名].str.replace(,).astype(int)# 3. 清洗總分字段轉(zhuǎn)換為浮點(diǎn)數(shù)處理空值/非數(shù)字defclean_score(score):try:returnfloat(score)except:returnNonedf[總分]df[總分].apply(clean_score)# 刪除總分仍為None的行dfdf.dropna(subset[總分])# 4. 去重按排名去重避免重復(fù)爬取dfdf.drop_duplicates(subset[排名],keepfirst)# 5. 重置索引dfdf.reset_index(dropTrue)# 保存清洗后的數(shù)據(jù)df.to_csv(qs2025_rank_clean.csv,indexFalse,encodingutf-8-sig)print(數(shù)據(jù)清洗完成已保存為qs2025_rank_clean.csv)print(清洗后數(shù)據(jù)前5行)print(df.head())# 基本數(shù)據(jù)信息print( 數(shù)據(jù)基本信息)print(df.info())print( 數(shù)據(jù)統(tǒng)計(jì)描述)print(df.describe())五、核心數(shù)據(jù)分析與可視化5.1 配置可視化環(huán)境解決中文顯示問(wèn)題importmatplotlib.pyplotasplt# 設(shè)置中文字體Windows系統(tǒng)plt.rcParams[font.sans-serif][SimHei]# 解決負(fù)號(hào)顯示問(wèn)題plt.rcParams[axes.unicode_minus]False# 設(shè)置圖表風(fēng)格plt.style.use(ggplot)5.2 分析1TOP50高校國(guó)家/地區(qū)分布# 篩選TOP50數(shù)據(jù)top50df[df[排名]50]# 統(tǒng)計(jì)國(guó)家/地區(qū)數(shù)量country_counttop50[國(guó)家/地區(qū)].value_counts()# 繪制柱狀圖plt.figure(figsize(12,6))country_count.plot(kindbar,colorsteelblue)plt.title(2025 QS世界大學(xué)排名TOP50 - 國(guó)家/地區(qū)分布,fontsize14)plt.xlabel(國(guó)家/地區(qū),fontsize12)plt.ylabel(高校數(shù)量,fontsize12)plt.xticks(rotation45)plt.tight_layout()# 調(diào)整布局避免文字重疊plt.savefig(top50_country_dist.png,dpi300)plt.show()# 輸出統(tǒng)計(jì)結(jié)果print(TOP50高校國(guó)家/地區(qū)分布)print(country_count)5.3 分析2主要國(guó)家TOP100高校數(shù)量對(duì)比# 篩選TOP100數(shù)據(jù)top100df[df[排名]100]# 篩選主要國(guó)家可按需調(diào)整main_countries[United States,United Kingdom,China,Japan,Germany,Canada,Australia]top100_maintop100[top100[國(guó)家/地區(qū)].isin(main_countries)]country_count_top100top100_main[國(guó)家/地區(qū)].value_counts()# 繪制餅圖plt.figure(figsize(10,10))plt.pie(country_count_top100.values,labelscountry_count_top100.index,autopct%1.1f%%,startangle90,colorsplt.cm.Set3.colors)plt.title(2025 QS世界大學(xué)排名TOP100 - 主要國(guó)家占比,fontsize14)plt.tight_layout()plt.savefig(top100_country_pie.png,dpi300)plt.show()print(主要國(guó)家TOP100高校數(shù)量)print(country_count_top100)5.4 分析3TOP100高??偡址植? 繪制直方圖plt.figure(figsize(10,6))plt.hist(top100[總分],bins15,colorlightcoral,edgecolorblack)plt.title(2025 QS世界大學(xué)排名TOP100 - 總分分布,fontsize14)plt.xlabel(總分,fontsize12)plt.ylabel(高校數(shù)量,fontsize12)plt.axvline(top100[總分].mean(),colorred,linestyle--,labelf平均分{top100[總分].mean():.2f})plt.legend()plt.tight_layout()plt.savefig(top100_score_dist.png,dpi300)plt.show()# 輸出總分統(tǒng)計(jì)print(TOP100高??偡纸y(tǒng)計(jì))print(f平均分{top100[總分].mean():.2f})print(f最高分{top100[總分].max():.2f})print(f最低分{top100[總分].min():.2f})print(f中位數(shù){top100[總分].median():.2f})5.5 分析4中國(guó)高校大陸港澳臺(tái)表現(xiàn)# 篩選中國(guó)高校大陸、中國(guó)香港、中國(guó)臺(tái)灣、中國(guó)澳門china_unisdf[df[國(guó)家/地區(qū)].str.contains(China,naFalse)]# 按排名排序china_unis_sortedchina_unis.sort_values(排名)print(2025 QS排名中中國(guó)高校TOP100)print(china_unis_sorted[china_unis_sorted[排名]100][[排名,學(xué)校名稱,國(guó)家/地區(qū),總分]])# 繪制中國(guó)高校TOP100的排名與總分散點(diǎn)圖china_top100china_unis_sorted[china_unis_sorted[排名]100]plt.figure(figsize(10,6))plt.scatter(china_top100[排名],china_top100[總分],colordarkgreen,s80)# 添加學(xué)校名稱標(biāo)注foridx,rowinchina_top100.iterrows():plt.annotate(row[學(xué)校名稱],(row[排名],row[總分]),fontsize8,haright)plt.title(2025 QS排名TOP100 - 中國(guó)高校排名vs總分,fontsize14)plt.xlabel(排名,fontsize12)plt.ylabel(總分,fontsize12)plt.tight_layout()plt.savefig(china_unis_scatter.png,dpi300)plt.show()六、完整代碼整合將以上步驟整合為一個(gè)完整腳本方便一鍵運(yùn)行importrequestsfrombs4importBeautifulSoupimportpandasaspdimporttimeimportmatplotlib.pyplotasplt# 1. 環(huán)境配置 # 可視化中文配置plt.rcParams[font.sans-serif][SimHei]plt.rcParams[axes.unicode_minus]Falseplt.style.use(ggplot)# 請(qǐng)求頭headers{User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36,Accept-Language:zh-CN,zh;q0.9,en;q0.8}# 2. 數(shù)據(jù)爬取 defcrawl_qs_rank():qs_data[]base_urlhttps://www.topuniversities.com/rankings/qs-world-university-rankings/2025?page{}forpageinrange(1,11):try:urlbase_url.format(page)responserequests.get(url,headersheaders,timeout10)response.raise_for_status()soupBeautifulSoup(response.text,lxml)rank_rowssoup.find_all(div,class_row indx)forrowinrank_rows:rankrow.find(div,class_rank).get_text(stripTrue)ifrow.find(div,class_rank)elseNoneuniversityrow.find(div,class_uni-name).get_text(stripTrue)ifrow.find(div,class_uni-name)elseNonecountryrow.find(div,class_location).get_text(stripTrue)ifrow.find(div,class_location)elseNonescorerow.find(div,class_overall-score-span).get_text(stripTrue)ifrow.find(div,class_overall-score-span)elseNoneqs_data.append({排名:rank,學(xué)校名稱:university,國(guó)家/地區(qū):country,總分:score})print(f第{page}頁(yè)爬取完成累計(jì){len(qs_data)}條)time.sleep(1)exceptExceptionase:print(f第{page}頁(yè)失敗{e})continuedfpd.DataFrame(qs_data)df.to_csv(qs2025_rank_raw.csv,indexFalse,encodingutf-8-sig)returndf# 3. 數(shù)據(jù)清洗 defclean_data(df):# 刪除缺失值dfdf.dropna(subset[排名,學(xué)校名稱,國(guó)家/地區(qū),總分])# 清洗排名df[排名]df[排名].str.replace(,).astype(int)# 清洗總分defclean_score(score):try:returnfloat(score)except:returnNonedf[總分]df[總分].apply(clean_score)dfdf.dropna(subset[總分])# 去重dfdf.drop_duplicates(subset[排名],keepfirst)dfdf.reset_index(dropTrue)df.to_csv(qs2025_rank_clean.csv,indexFalse,encodingutf-8-sig)print(數(shù)據(jù)清洗完成保存為qs2025_rank_clean.csv)returndf# 4. 數(shù)據(jù)分析與可視化 defanalyze_data(df):# 4.1 TOP50國(guó)家分布top50df[df[排名]50]country_counttop50[國(guó)家/地區(qū)].value_counts()plt.figure(figsize(12,6))country_count.plot(kindbar,colorsteelblue)plt.title(2025 QS TOP50 - 國(guó)家/地區(qū)分布,fontsize14)plt.xlabel(國(guó)家/地區(qū),fontsize12)plt.ylabel(數(shù)量,fontsize12)plt.xticks(rotation45)plt.tight_layout()plt.savefig(top50_country_dist.png,dpi300)plt.show()# 4.2 主要國(guó)家TOP100占比top100df[df[排名]100]main_countries[United States,United Kingdom,China,Japan,Germany,Canada,Australia]top100_maintop100[top100[國(guó)家/地區(qū)].isin(main_countries)]country_count_top100top100_main[國(guó)家/地區(qū)].value_counts()plt.figure(figsize(10,10))plt.pie(country_count_top100.values,labelscountry_count_top100.index,autopct%1.1f%%,startangle90,colorsplt.cm.Set3.colors)plt.title(2025 QS TOP100 - 主要國(guó)家占比,fontsize14)plt.tight_layout()plt.savefig(top100_country_pie.png,dpi300)plt.show()# 4.3 TOP100總分分布plt.figure(figsize(10,6))plt.hist(top100[總分],bins15,colorlightcoral,edgecolorblack)plt.axvline(top100[總分].mean(),colorred,linestyle--,labelf平均分{top100[總分].mean():.2f})plt.title(2025 QS TOP100 - 總分分布,fontsize14)plt.xlabel(總分,fontsize12)plt.ylabel(數(shù)量,fontsize12)plt.legend()plt.tight_layout()plt.savefig(top100_score_dist.png,dpi300)plt.show()# 4.4 中國(guó)高校表現(xiàn)china_unisdf[df[國(guó)家/地區(qū)].str.contains(China,naFalse)]china_top100china_unis[china_unis[排名]100].sort_values(排名)print(中國(guó)高校TOP100)print(china_top100[[排名,學(xué)校名稱,國(guó)家/地區(qū),總分]])plt.figure(figsize(10,6))plt.scatter(china_top100[排名],china_top100[總分],colordarkgreen,s80)foridx,rowinchina_top100.iterrows():plt.annotate(row[學(xué)校名稱],(row[排名],row[總分]),fontsize8,haright)plt.title(2025 QS TOP100 - 中國(guó)高校排名vs總分,fontsize14)plt.xlabel(排名,fontsize12)plt.ylabel(總分,fontsize12)plt.tight_layout()plt.savefig(china_unis_scatter.png,dpi300)plt.show()# 主函數(shù) if__name____main__:# 爬取數(shù)據(jù)若已爬取可注釋直接加載raw_dfcrawl_qs_rank()# 清洗數(shù)據(jù)clean_dfclean_data(raw_df)# 分析數(shù)據(jù)analyze_data(clean_df)七、分析結(jié)果解讀示例TOP50分布美國(guó)依舊占據(jù)主導(dǎo)地位約20所英國(guó)次之約8所中國(guó)內(nèi)地有5所左右進(jìn)入TOP50TOP100占比美國(guó)占比超40%英國(guó)約15%中國(guó)含港澳臺(tái)約8%總分分布TOP100高??偡旨性?0-95分區(qū)間前10名總分均超90分分?jǐn)?shù)差距隨排名提升逐漸縮小中國(guó)高校清華大學(xué)、北京大學(xué)穩(wěn)居中國(guó)高校榜首進(jìn)入TOP20中國(guó)香港的香港大學(xué)、香港科技大學(xué)也表現(xiàn)亮眼躋身TOP50。八、拓展方向爬取歷年QS排名數(shù)據(jù)分析高校排名變化趨勢(shì)加入更多維度分析如學(xué)科排名、師生比、國(guó)際生比例等結(jié)合地理信息繪制全球高校分布熱力圖用機(jī)器學(xué)習(xí)預(yù)測(cè)高校排名變化如基于總分、學(xué)科表現(xiàn)等特征。九、注意事項(xiàng)爬取數(shù)據(jù)時(shí)需遵守網(wǎng)站robots.txt協(xié)議避免高頻請(qǐng)求QS官網(wǎng)頁(yè)面結(jié)構(gòu)可能更新需及時(shí)調(diào)整爬蟲(chóng)的CSS選擇器數(shù)據(jù)僅供學(xué)習(xí)使用請(qǐng)勿用于商業(yè)用途??偨Y(jié)本文通過(guò)Python完成了QS世界大學(xué)排名的全流程分析從數(shù)據(jù)爬取到可視化覆蓋了數(shù)據(jù)分析的核心環(huán)節(jié)。掌握這套思路后你可以舉一反三分析其他排名如泰晤士、U.S. News或行業(yè)數(shù)據(jù)。希望本文能幫助你提升Python數(shù)據(jù)分析能力也為留學(xué)選校、高校研究提供參考
版權(quán)聲明: 本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)聯(lián)系我們進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

php開(kāi)源網(wǎng)站在線簡(jiǎn)歷模板

php開(kāi)源網(wǎng)站,在線簡(jiǎn)歷模板,營(yíng)銷型網(wǎng)站策劃,wordpress 新建模板頁(yè)還在為跨平臺(tái)編碼體驗(yàn)不一致而苦惱#xff1f;每次切換系統(tǒng)都要重新適應(yīng)不同的編輯器設(shè)置#xff1f;notepad--正是為

2026/01/23 10:44:01

國(guó)外網(wǎng)站做盜版百度關(guān)鍵詞排名查詢

國(guó)外網(wǎng)站做盜版,百度關(guān)鍵詞排名查詢,威海制作網(wǎng)站,wordpress 寫(xiě)插件嗎深入理解USB轉(zhuǎn)串口通信#xff1a;從芯片識(shí)別到驅(qū)動(dòng)安裝的完整實(shí)戰(zhàn)指南 你有沒(méi)有遇到過(guò)這樣的情況#xff1f; 手里

2026/01/22 22:51:01

網(wǎng)站收錄有什么用代理公司注冊(cè)價(jià)格

網(wǎng)站收錄有什么用,代理公司注冊(cè)價(jià)格,asp.net企業(yè)網(wǎng)站建設(shè),免費(fèi)小程序網(wǎng)站寫(xiě)論文最怕什么#xff1f;不是寫(xiě)不出來(lái)#xff0c;而是寫(xiě)出來(lái)被系統(tǒng)一測(cè)#xff0c;AI率高得嚇人。明明自己花了不少心

2026/01/22 22:45:01

怎么樣讓百度收錄網(wǎng)站怎么網(wǎng)站設(shè)計(jì)

怎么樣讓百度收錄網(wǎng)站,怎么網(wǎng)站設(shè)計(jì),網(wǎng)絡(luò)營(yíng)銷推廣方案內(nèi)容,定制禮品SubtitleEdit語(yǔ)音轉(zhuǎn)文字功能完整配置指南與故障排查 【免費(fèi)下載鏈接】subtitleedit the subtitle ed

2026/01/23 08:48:01

婚紗攝影網(wǎng)站開(kāi)發(fā)舞臺(tái)快速搭建

婚紗攝影網(wǎng)站開(kāi)發(fā),舞臺(tái)快速搭建,frog 網(wǎng)站建設(shè),北京最新新聞事件一、引言在 Flutter 開(kāi)發(fā)中#xff0c;狀態(tài)管理#xff08;State Management#xff09; 是繞不開(kāi)的核心

2026/01/22 23:19:01

小型網(wǎng)站建設(shè)公司網(wǎng)站建設(shè) 010

小型網(wǎng)站建設(shè)公司,網(wǎng)站建設(shè) 010,網(wǎng)站建設(shè)與管理試題答案,免費(fèi)商品列表網(wǎng)頁(yè)模板源代碼目錄 8.1圖像色彩調(diào)整基礎(chǔ) 8.1.1 色彩模式的轉(zhuǎn)換 1. 色彩模式轉(zhuǎn)換注意問(wèn)題 2. 各種色彩模式之

2026/01/23 02:17:01