国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像

這篇具有很好參考價值的文章主要介紹了數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

Tips:"分享是快樂的源泉??,在我的博客里,不僅有知識的海洋??,還有滿滿的正能量加持??,快來和我一起分享這份快樂吧??!

喜歡我的博客的話,記得點(diǎn)個紅心??和小關(guān)小注哦!您的支持是我創(chuàng)作的動力!數(shù)據(jù)源存放在我的資源下載區(qū)啦!

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams["font.family"]=['SimHei']
plt.rcParams['axes.unicode_minus']=False

1. 爬取NBA球隊排名頁面,并進(jìn)行分析

  • 頁面url https://nba.hupu.com/standings

提示:

data = pd.read_html(url, header=0) #header=0 去掉第一行列索引
# 爬取數(shù)據(jù)并將東部和西部聯(lián)盟存放到df1 df2
url = "https://nba.hupu.com/standings"
data = pd.read_html(url,header=0) #header=0 去掉第一行列索引
data_merge = pd.concat([df,data[0]])

data_merge.columns = data_merge.iloc[0,:]
data_merge = data_merge.iloc[1:]

# 重置索引,不保留原索引作為新列  
data_merge.reset_index(drop=True, inplace=True)  


數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 東部數(shù)據(jù)
df1 = data_merge.iloc[0:15,:]
df1

# 西部數(shù)據(jù)
df2 = data_merge.iloc[17:,:]
df2.reset_index(drop=True, inplace=True)  
df2

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 將df1增加一列"所屬聯(lián)盟",賦值為"東部賽區(qū)"
df1["所屬聯(lián)盟"] = "東部賽區(qū)"
df1

# 將df2增加一列"所屬聯(lián)盟",賦值為"西部賽區(qū)"
df2["所屬聯(lián)盟"] = "西部賽區(qū)"
df2

# 將df1、df2合并成df
df_merge = pd.concat([df1,df2], axis = 0)
df_merge.reset_index(drop=True,inplace=True)
df_merge

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 將df數(shù)據(jù)保存為csv文件 nba.csv
df_merge.to_csv('./nba.csv', encoding='utf-8', index=False,sep=",")
# 將所有球隊按照 勝率(百分比) 降序排序,排名相同的隊伍按 失分 升序排名
# 提示:ascending也可以接收列表參數(shù)
df_merge.sort_values(by=["勝率","失分"],ascending=[False,True]).reset_index(drop=True)

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 對df按“所屬聯(lián)盟”分組,計算勝、負(fù)、勝率的最大值、最小值、均值、標(biāo)準(zhǔn)差
# 注意:百分比不是數(shù)值,要轉(zhuǎn)換成小數(shù)
# 轉(zhuǎn)換數(shù)值類型
df_merge["勝"] = df_merge["勝"].astype(int)
df_merge["負(fù)"] = df_merge["負(fù)"].astype(int)
# 將百分比字符串轉(zhuǎn)換為小數(shù)  
df_merge['勝率'] = df_merge['勝率'].str.replace('%', '').astype(float) / 100
df_merge.head()

df_grouped = df_merge.groupby(by='所屬聯(lián)盟').agg(
    {  
    '勝': ['max', 'min', 'mean', 'std'],  
    '負(fù)': ['max', 'min', 'mean', 'std'],  
    '勝率': ['max', 'min', 'mean', 'std']  
})  

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 柱狀圖顯示東西賽區(qū)的勝率(百分比)均值
# 提取勝率均值列,并重置列名以簡化后續(xù)操作  
df_grouped_win_rate_mean = df_grouped['勝率']['mean'].reset_index()  
df_grouped_win_rate_mean.columns = ['所屬聯(lián)盟', '勝率均值']  
df_grouped_win_rate_mean

# 將勝率均值轉(zhuǎn)換為百分比  
df_grouped_win_rate_mean['勝率均值_百分比'] = df_grouped_win_rate_mean['勝率均值'] * 100  
df_grouped_win_rate_mean

# 繪制柱狀圖  
plt.figure(figsize=(10, 6))  # 設(shè)置圖形大小  
bars = plt.bar(df_grouped_win_rate_mean['所屬聯(lián)盟'], df_grouped_win_rate_mean['勝率均值_百分比'])  
  
# 設(shè)置數(shù)據(jù)標(biāo)簽  
def format_percent(x):  
    return "{:.2%}".format(x / 100)  
  
# 添加百分比形式的數(shù)據(jù)標(biāo)簽  
for rect in bars:  
    height = rect.get_height()  
    plt.text(rect.get_x() + rect.get_width() / 2, height, format_percent(height),  
             ha='center', va='bottom')  

plt.xlabel('所屬聯(lián)盟')  # 設(shè)置x軸標(biāo)簽  
plt.ylabel('勝率均值')  # 設(shè)置y軸標(biāo)簽  
plt.title('東西賽區(qū)勝率均值比較')  # 設(shè)置圖形標(biāo)題  
plt.xticks(rotation=0)  # 設(shè)置x軸刻度標(biāo)簽的旋轉(zhuǎn)角度為0  
plt.tight_layout()  # 調(diào)整布局  
plt.ylabel('勝率均值 (%)')  # 將y軸標(biāo)簽更改為百分比形式  
plt.show()  # 顯示圖形

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

2. 爬取以下網(wǎng)址的歷年中國人口數(shù)據(jù)進(jìn)行并進(jìn)行分析

url = ‘https://population.gotohui.com/’

# 爬取數(shù)據(jù)并存放到df,并將df保存為population.csv
url = 'https://population.gotohui.com/'
data = pd.read_html(url,header=0) #header=0 去掉第一行列索引

df = data[0]
df.to_csv("./population.csv", encoding='utf-8', index=False,sep=",")

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 統(tǒng)計df表格中的空值
# 檢測空值  
null_values = df.isnull() 
total_null_count = null_values.sum()  
total_null_count

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 將空值的列'老年人(%)'、'兒童(%)'中數(shù)據(jù)用前值替換;'男性(%)'、'女性(%)'用均值替換
# 使用前一個非空值替換 '老年人(%)' 和 '兒童(%)' 列中的空值  
df['老年(%)'].fillna(method='ffill', inplace=True)  
df['兒童(%)'].fillna(method='ffill', inplace=True)  

# 計算 '男性(%)' 和 '女性(%)' 列的均值,并替換這些列中的空值  
mean_male = df['男性(%)'].mean()  
mean_female = df['女性(%)'].mean()  
df['男性(%)'].fillna(mean_male, inplace=True)  
df['女性(%)'].fillna(mean_female, inplace=True) 
df

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 將除了 時間(年) 列外所有的列的數(shù)據(jù)改成保留小數(shù)點(diǎn)后2位小數(shù)
# 提示:采用lambda函數(shù)和applymap函數(shù)
# 保留除了'時間'字段之外的列的小數(shù)點(diǎn)后兩位  
columns_to_round = ['人口(萬人)', '出生率(‰)', '增長率(‰)', '老年(%)', '兒童(%)', '男性(%)', '女性(%)']  
  
df[columns_to_round] = df[columns_to_round].apply(lambda x: x.round(2))  
  
# 查看格式化后的輸出,可以設(shè)置顯示選項 (空值輸出時浮點(diǎn)數(shù)格式)
pd.options.display.float_format = '{:.2f}'.format 

# 顯示修改后的DataFrame  
df.head()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 在同一張表上繪制歷年人口出生率和增長率曲線
# 確保'時間'列是日期類型,這樣可以按時間順序繪制曲線  
df['時間'] = pd.to_datetime(df['時間'], format='%Y')  # 假設(shè)時間格式為'年'  
  
# 繪制出生率曲線  
plt.plot(df['時間'], df['出生率(‰)'], label='出生率(‰)', marker='o')  
  
# 繪制增長率曲線  
plt.plot(df['時間'], df['增長率(‰)'], label='增長率(‰)', marker='o', linestyle='--')  
  
# 設(shè)置圖表標(biāo)題和坐標(biāo)軸標(biāo)簽  
plt.title('歷年人口出生率和增長率曲線')  
plt.xlabel('時間')  
plt.ylabel('比率')  
  
# 顯示圖例  
plt.legend()  
  
# 顯示網(wǎng)格  
plt.grid(True)  
  
# 格式化x軸以顯示年份  
plt.gcf().autofmt_xdate()  
  
# 顯示圖表  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 繪制男女比率差絕對值的曲線圖
# 計算男女比率差的絕對值  
df['比率差絕對值'] = abs(df['男性(%)'] - df['女性(%)'])  
df

# 繪制男女比率差絕對值的曲線圖  
plt.plot(df['時間'], df['比率差絕對值'], marker='o')  
  
# 設(shè)置圖表標(biāo)題和坐標(biāo)軸標(biāo)簽  
plt.title('男女比率差絕對值曲線圖')  
plt.xlabel('時間')  
plt.ylabel('比率差絕對值')  
  
# 顯示網(wǎng)格  
plt.grid(True)    
  
# 顯示圖表  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 在一個畫布的四個子畫布上(兩行兩列)分別畫出:
# 1、近十年老人、兒童、其它(100減去老人、兒童占比)人群比率均值的柱狀比較圖
# 2、近五年男性、女性比率的柱狀比較圖
# 3、近十年人口增增長率和出生率的水平柱狀圖
# 4、2022年老人、兒童、其它的餅圖

import matplotlib.pyplot as plt  
import pandas as pd  
  
# 假設(shè)df_1, df_2, df_3, df_4已經(jīng)定義好,并且包含了需要繪制的數(shù)據(jù)  
  
# 創(chuàng)建一個2x2的畫布和子圖  
fig, axs = plt.subplots(2, 2, figsize=(12, 8))  
  
# 第一幅圖:近十年老人、兒童、其它人群比率均值的柱狀比較圖  
bars = axs[0, 0].bar(df_1.columns, df_1.iloc[0])  
bar_width = 0.35  
axs[0, 0].set_title('近十年老人、兒童、其它人群比率均值的柱狀比較圖')  
axs[0, 0].set_xlabel('人群')  
axs[0, 0].set_ylabel('比率均值(%)')  
for bar in bars:  
    height = bar.get_height()  
    axs[0, 0].text(bar.get_x() + bar_width / 2, height, '{:.2f}'.format(height), ha='center', va='bottom')  
  
 # 第二幅圖:近五年男性和女性比例的柱狀比較圖  
df_2 = df_2.sort_values(by='時間')  
bar_width = 0.35  
index_male = range(len(df_2))  
index_female = [i + bar_width for i in index_male]  
  
axs[0, 1].bar(index_male, df_2['男性(%)'], bar_width, label='男性比例')  
axs[0, 1].bar(index_female, df_2['女性(%)'], bar_width, label='女性比例')  
  
# 設(shè)置x軸的標(biāo)簽位置為index_male的中間位置,并且標(biāo)簽內(nèi)容為df_2['時間']的值  
tick_positions = [i + bar_width / 2 for i in index_male]  
axs[0, 1].set_xticks(tick_positions)  
axs[0, 1].set_xticklabels(df_2['時間'])  # 設(shè)置x軸的標(biāo)簽內(nèi)容  
  
# 設(shè)置x軸刻度標(biāo)簽的旋轉(zhuǎn)角度  
axs[0, 1].tick_params(axis='x', rotation=45)  # 旋轉(zhuǎn)x軸刻度標(biāo)簽  
  
axs[0, 1].set_title('近五年男性和女性比例的柱狀比較圖')  
axs[0, 1].set_xlabel('年份')  
axs[0, 1].set_ylabel('比例(%)')  
axs[0, 1].legend()  
  
# 第三幅圖:近十年人口增長率和出生率水平柱狀圖  
axs[1, 0].barh(df_3['時間'], df_3['增長率(‰)'], label='增長率', color='skyblue')  
axs[1, 0].barh(df_3['時間'], df_3['出生率(‰)'], left=df_3['增長率(‰)'], label='出生率', color='lightcoral')  
axs[1, 0].set_title('近十年人口增長率和出生率水平柱狀圖')  
axs[1, 0].set_xlabel('千分比')  
axs[1, 0].set_ylabel('年份')  
axs[1, 0].legend()  
axs[1, 0].grid(axis='x', alpha=0.75)  
  
# 第四幅圖:2022年老人、兒童、其他人群分布的餅圖  
labels = df_4.columns  
sizes = df_4.iloc[0]  
axs[1, 1].pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)  
axs[1, 1].axis('equal')  
axs[1, 1].set_title('2022年老人、兒童、其他人群分布')  
  
# 調(diào)整子圖間距  
plt.tight_layout()  
  
# 顯示整個畫布  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 在同一幅圖上畫出'出生率(‰)', '增長率(‰)'箱線圖。
import seaborn as sns  
import matplotlib.pyplot as plt  
  
# 設(shè)置圖形大小  
plt.figure(figsize=(10, 6))  
  
# 繪制箱線圖  
sns.boxplot(data=df[['出生率(‰)', '增長率(‰)']])  
 
# 設(shè)置標(biāo)題和軸標(biāo)簽  
plt.title('出生率和增長率的箱線圖')  
plt.xlabel('指標(biāo)')  
plt.ylabel('值 (‰)')  
  
# 顯示圖形  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 利用散點(diǎn)圖尋找 ‘增長率(‰)’ 異常值的年份,即尋找增長率背離正常變化范圍的年份。
import matplotlib.pyplot as plt  
import pandas as pd  
import numpy as np  
  
# 計算增長率的四分位數(shù)  
Q1 = df_6['增長率(‰)'].quantile(0.25)  
Q3 = df_6['增長率(‰)'].quantile(0.75)  

  
# 定義正常值范圍,這里使用0.8倍IQR作為異常值的界限  
lower_bound = Q1 - 0.8 * IQR  
upper_bound = Q3 + 0.8 * IQR  
  
# 識別異常值  
outliers = df_6[(df_6['增長率(‰)'] < lower_bound) | (df_6['增長率(‰)'] > upper_bound)]  
  
# 繪制散點(diǎn)圖  
plt.figure(figsize=(10, 6))  
plt.scatter(df_6['時間'], df_6['增長率(‰)'], color='blue', label='正常值')  
  
# 在圖上標(biāo)注異常值  
plt.scatter(outliers['時間'], outliers['增長率(‰)'], color='red', label='異常值')  
for index, row in outliers.iterrows():  
    plt.annotate(f'({row["時間"]}, {row["增長率(‰)"]})', (row['時間'], row['增長率(‰)']))  

# 設(shè)置標(biāo)題和軸標(biāo)簽  
plt.title('增長率隨時間變化的散點(diǎn)圖及異常值標(biāo)注')  
plt.xlabel('時間')  
plt.ylabel('增長率(‰)')  
  
# 顯示圖例  
plt.legend()  
  
# 顯示網(wǎng)格線  
plt.grid(True)  
  
# 顯示圖形  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 利用正態(tài)分布方法(類似3??方法,采用1.5??)找出增長率異常值
import pandas as pd  
import numpy as np  
import matplotlib.pyplot as plt  
  
# 計算增長率的均值和標(biāo)準(zhǔn)差  
mean_growth_rate = df_7['增長率(‰)'].mean()  
std_growth_rate = df_7['增長率(‰)'].std()  
  
# 設(shè)定異常值的閾值,這里使用1.5倍標(biāo)準(zhǔn)差  
threshold = mean_growth_rate + 1.5 * std_growth_rate  
# 對于低于均值的異常值,使用負(fù)的1.5倍標(biāo)準(zhǔn)差  
lower_threshold = mean_growth_rate - 1.5 * std_growth_rate  
  
# 識別異常值  
outliers_upper = df_7[df_7['增長率(‰)'] > threshold]  
outliers_lower = df_7[df_7['增長率(‰)'] < lower_threshold]  
outliers = pd.concat([outliers_upper, outliers_lower])  
  
# 繪制散點(diǎn)圖,并標(biāo)注異常值  
plt.figure(figsize=(10, 6))  
plt.scatter(df_7['時間'], df_7['增長率(‰)'], color='blue', label='正常值')  
  
# 標(biāo)注異常值  
plt.scatter(outliers['時間'], outliers['增長率(‰)'], color='red', label='異常值')  
for index, row in outliers.iterrows():  
    plt.annotate(f'({row["時間"]}, {row["增長率(‰)"]})', (row['時間'], row['增長率(‰)']))  

# 設(shè)置標(biāo)題和軸標(biāo)簽  
plt.title('增長率隨時間變化的散點(diǎn)圖及異常值標(biāo)注')  
plt.xlabel('時間')  
plt.ylabel('增長率(‰)')  
  
# 顯示圖例  
plt.legend()  
  
# 顯示網(wǎng)格線  
plt.grid(True)  
  
# 顯示圖形  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

3. 獲取大學(xué)排名數(shù)據(jù)并進(jìn)行分析

  • 獲取數(shù)據(jù)地址:http://www.jdxzz.com/paiming/2022/0830/9651208.html
  • 數(shù)據(jù)爬取后,存在“主榜”和“副榜”,只保留主榜數(shù)據(jù)

提示:

data = pd.read_html(url, header=0) #header=0 去掉第一行列索引
df = pd.DataFrame(data[0]) # 只獲取主榜表格數(shù)據(jù)
# 獲取“主榜”數(shù)據(jù)并放入df
# 將數(shù)據(jù)保存到universities.csv
url = 'http://www.jdxzz.com/paiming/2022/0830/9651208.html'
data = pd.read_html(url,header=0) #header=0 去掉第一行列索引
data

df = data[0]
df.to_csv("../data/universities.csv", encoding='utf-8', index=False,sep=",")

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 不同 辦學(xué)層次 的大學(xué)數(shù)量?
# 畫出不同 辦學(xué)層次 的大學(xué)數(shù)量的折線圖,按升序畫
df_group = df.groupby(by='辦學(xué)層次')["辦學(xué)層次"].count().reset_index(name='數(shù)量')
df_group = df_group.sort_values(by='數(shù)量',ascending=True).reset_index(drop=True)
df_group

import matplotlib.pyplot as plt  
  
# 繪制折線圖  
plt.figure(figsize=(10, 6))  # 設(shè)置圖形大小  
plt.plot(df_group['辦學(xué)層次'], df_group['數(shù)量'], marker='o')  # 繪制折線,并使用圓圈標(biāo)記數(shù)據(jù)點(diǎn)  
  
# 設(shè)置標(biāo)題和軸標(biāo)簽  
plt.title('不同辦學(xué)層次的大學(xué)數(shù)量折線圖')  
plt.xlabel('辦學(xué)層次')  
plt.ylabel('數(shù)量')  
  
# 顯示網(wǎng)格線  
plt.grid(True)  
  
# 顯示圖形  
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 顯示只包含 財經(jīng)大學(xué)、財經(jīng)學(xué)院 的子表,并按排名排列
# 提示:Pandas 中類似SQL中的like查詢
# df.query('column.str.contains("string")', engine='python')

df_gdufe = df.query('學(xué)校名稱.str.contains("財經(jīng)")', engine='python').reset_index(drop=True)
df_gdufe

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 計算不同 辦學(xué)層次 大學(xué)的 總分均值、排名均值,四舍五入取一位小數(shù)
df_grouped = df.groupby(by='辦學(xué)層次').agg(
    {  
    '總分': 'mean',  
    '全國排名': 'mean'  
}).round(1)

df_grouped.columns = ["總分均值","排名均值"]
df_grouped

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

4. 獲取sina股票數(shù)據(jù)并進(jìn)行分析

  • 獲取數(shù)據(jù)地址:http://vip.stock.finance.sina.com.cn/q/go.php/vComStockHold/kind/jjzc/index.phtml?p=
  • 數(shù)據(jù)分6頁,p=1代表第1頁

提示

df = pd.DataFrame()
for i in range(6):    
    url = 'http://vip.stock.finance.sina.com.cn/q/go.php/vComStockHold/kind/jjzc/index.phtml?p={page}'.format(page=i+1)
    df = pd.concat([df, pd.read_html(url)[0]]) # 按行連接
    print("第{page}頁爬取成功!".format(page=i+1))
# 爬取6頁表格數(shù)據(jù)并合并數(shù)據(jù)到df,再保存到sina.csv文件
df.to_csv('../data/sina.csv', encoding='utf-8', index=False,sep=",")
# 從sina.csv中讀取到df,并隨機(jī)顯示10行數(shù)據(jù)
df = pd.read_csv(fr"../data/sina.csv",encoding='utf-8', sep=",")
df.sample(10)

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 基金持股比例最高的10個股份的 代碼 簡稱 比例
df_top = df.sort_values(by="持股比例(%)",ascending=False).reset_index(drop=True)[["代碼","簡稱","持股比例(%)"]]
df_top.head(10)

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 按照持股家數(shù)分組 計算 持股占已流通A股比例(%) 的平均數(shù) 降序
df.groupby(by="家數(shù)")[["持股占已流通A股比例(%)"]].mean().sort_values(by="持股占已流通A股比例(%)",ascending=False)

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 統(tǒng)計銀行的平均 家數(shù) 和 平均 持股比例(%) (簡稱含有銀行字眼)
df_bank = df.query('簡稱.str.contains("銀行")', engine='python').reset_index(drop=True)[["簡稱","家數(shù)","持股比例(%)"]]
df_bank

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 統(tǒng)計家數(shù)增加最多的10個股票,按 持股占已流通A股比例(%) 降序排序
df["增加家數(shù)"] = df["家數(shù)"] - df["上期家數(shù)"]
df.head()

df_10 = df.sort_values(by="增加家數(shù)",ascending=False).reset_index(drop=True).head(10)
df_10

df_10.sort_values(by="持股占已流通A股比例(%)",ascending=False).reset_index(drop=True)

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 將 持股占已流通A股比例(%)>8 同時 持股比例(%)>5 的股票挑選出來
df.loc[(df["持股占已流通A股比例(%)"] > 8) & (df["持股比例(%)"] > 5)]

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 將%號加到 持股占已流通A股比例(%) 和 持股比例(%) 兩列, 元素值改為字符串
# 使用apply和lambda表達(dá)式添加%號,并轉(zhuǎn)換為字符串  
df['持股占已流通A股比例(%)'] = df['持股占已流通A股比例(%)'].apply(lambda x: f"{x}%" if not pd.isna(x) else pd.NA)  
df['持股比例(%)'] = df['持股比例(%)'].apply(lambda x: f"{x}%" if not pd.isna(x) else pd.NA)  
  
# 查看修改后的DataFrame  
df

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

5. matplotlib模仿繪圖

按繪圖樣式,寫出繪制代碼。

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 代碼
# 創(chuàng)建?些數(shù)據(jù)
x1 = np.linspace(0, 5, 100)
x2 = np.linspace(0, 2*np.pi, 100)
x3 = np.linspace(0, 2*np.pi, 100)

y1 = np.sin(2*np.pi*x1)
y2 = np.sin(x2)
y3 = np.cos(x3)
# 創(chuàng)建?個新的Figure,包含2x2個Axes
fig = plt.figure(figsize=(16, 12))
# 在2x2?格中創(chuàng)建4個Axes

# =========================================第一幅圖=========================================
plt.subplot(2, 2, 1) # 第??第?個
plt.plot(x1, y1, linestyle='-')
# 設(shè)置左上角的子圖橫坐標(biāo)范圍為0到5(留白效果),縱坐標(biāo)范圍為-2.0到2.0  
plt.xlim(-0.3, 5.3)  
plt.ylim(-2.0, 2.0)  
plt.xlabel("x軸")
plt.ylabel("y軸")

# =========================================第二幅圖=========================================
plt.subplot(2, 2, 2) # 第??第?個
plt.plot(x2, y2, linestyle='-.',color='m')
# 設(shè)置橫坐標(biāo)的刻度位置和標(biāo)簽  
ticks = np.arange(0, 2 * np.pi + np.pi/4, np.pi/2)  # 刻度位置:從0開始,每隔π/2一個刻度  
labels = [r'$0$', r'$\frac{\pi}{2}$', r'$\pi$', r'$\frac{3\pi}{2}$', r'$2\pi$']  # 對應(yīng)的標(biāo)簽  
plt.xticks(ticks, labels)  # 設(shè)置刻度和標(biāo)簽  
  
# 設(shè)置橫坐標(biāo)范圍,稍微擴(kuò)大以留下空白  
plt.xlim(-0.3, 2 * np.pi + 0.3)  
plt.ylim(-1.5, 1.5) 
plt.xlabel("y=sin(x)")

# =========================================第三幅圖=========================================
plt.subplot(2, 2, 3) # 第??第?個
plt.plot(x3, y3, linestyle='--',color='m')
# 設(shè)置橫坐標(biāo)的刻度位置和標(biāo)簽  
ticks = np.arange(0, 2 * np.pi + np.pi/4, np.pi/2)  # 刻度位置:從0開始,每隔π/2一個刻度  
labels = [r'$0$', r'$\frac{\pi}{2}$', r'$\pi$', r'$\frac{3\pi}{2}$', r'$2\pi$']  # 對應(yīng)的標(biāo)簽  
plt.xticks(ticks, labels)  # 設(shè)置刻度和標(biāo)簽  
  
# 設(shè)置橫坐標(biāo)范圍,稍微擴(kuò)大以留下空白  
plt.xlim(-0.3, 2 * np.pi + 0.3)  
plt.ylim(-1.5, 1.5)  
plt.xlabel("y=cos(x)")

plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

6. matplotlib模仿繪圖

按繪圖樣式,寫出繪制代碼。

  • 繪圖函數(shù):y=sin(x), y=cos(x), x = np.linspace(-np.pi, np.pi, 256, endpoint=True)
  • 繪制填充區(qū)域: 紫色區(qū)域:(-2.5<x)&(x<-0.5),綠色區(qū)域:sinx>0.5

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html

# 代碼
import numpy as np
import matplotlib.pyplot as plt

# 創(chuàng)建一個大小為(10, 6)的圖像,設(shè)置分辨率為80
plt.figure(figsize=(10,6), dpi=80)

# 生成一個從-pi到pi的256個點(diǎn)的等差數(shù)列
x = np.linspace(-np.pi, np.pi, 256, endpoint=True)

# 計算x對應(yīng)的sin和cos值
C, S = np.cos(x), np.sin(x)

# 繪制sin(x)曲線,設(shè)置顏色為藍(lán)色,線寬為2.5,線型為實(shí)線
plt.plot(x, S, color="blue", linewidth=2.5, linestyle="-", label=r'$sin(x)$')

# 繪制cos(x)曲線,設(shè)置顏色為紅色,線寬為2.5,線型為實(shí)線
plt.plot(x, C, color="red", linewidth=2.5, linestyle="-", label=r'$cos(x)$')

# 填充cos(x)曲線在x范圍(-2.5, -0.5)之間的區(qū)域,顏色為深紫色(DarkViolet),透明度為0.5
plt.fill_between(x, C, where=((-2.5 < x) & (x < -0.5)), color='DarkViolet', alpha=0.5)

# 填充sin(x)曲線在值大于0.5的區(qū)域,顏色為深綠色(DarkGreen),透明度為0.5
plt.fill_between(x, S, where=(S > 0.5), color='DarkGreen', alpha=0.5)

# 添加圖例,位于左上角,并設(shè)置圖例的背景色為白色
plt.legend(loc='upper left', facecolor='white')

# 設(shè)置x軸和y軸的范圍
plt.xlim(x.min()*1.2, x.max()*1.2)
plt.ylim(C.min()*1.2, C.max()*1.2)

# 設(shè)置x軸和y軸的刻度標(biāo)簽
plt.xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$'])
plt.yticks([-1,1], [r'$-1$', r'$1$'])

# 移動坐標(biāo)軸到原點(diǎn)
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.spines['bottom'].set_position(('data',0))
ax.spines['left'].set_position(('data',0))

# 設(shè)置特殊點(diǎn)的標(biāo)記和注釋
t = 2*np.pi/3
plt.plot([t,t],[0,np.cos(t)], color ='red', linewidth=2.5, linestyle="--")
plt.scatter([t,],[np.cos(t),], 50, color ='red')
plt.annotate(r'$sin(\frac{2\pi}{3})=\frac{\sqrt{3}}{2}$',
             xy=(t, np.sin(t)), xycoords='data',
             xytext=(+10, +30), textcoords='offset points', fontsize=16,
             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))

plt.plot([t,t],[0,np.sin(t)], color ='blue', linewidth=2.5, linestyle="--")
plt.scatter([t,],[np.sin(t),], 50, color ='blue')
plt.annotate(r'$cos(\frac{2\pi}{3})=-\frac{1}{2}$',
             xy=(t, np.cos(t)), xycoords='data',
             xytext=(-90, -50), textcoords='offset points', fontsize=16,
             arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=.2"))

# 添加標(biāo)題,并設(shè)置標(biāo)題的顏色為綠色,位置為中心
plt.title('繪圖實(shí)例之SIN()&COS()', color="green", loc="center")

# 添加網(wǎng)格線
plt.grid(True)

# 顯示圖像
plt.show()

數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像,數(shù)據(jù)可視化,信息可視化,pandas,python,numpy,conda,爬蟲,html文章來源地址http://www.zghlxwxcb.cn/news/detail-856907.html

到了這里,關(guān)于數(shù)據(jù)可視化(六):Pandas爬取NBA球隊排名、爬取歷年中國人口數(shù)據(jù)、爬取中國大學(xué)排名、爬取sina股票數(shù)據(jù)、繪制精美函數(shù)圖像的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Python爬取貓眼電影票房 + 數(shù)據(jù)可視化

    Python爬取貓眼電影票房 + 數(shù)據(jù)可視化

    對貓眼電影票房進(jìn)行爬取,首先我們打開貓眼 接著我們想要進(jìn)行數(shù)據(jù)抓包,就要看網(wǎng)站的具體內(nèi)容,通過按F12,我們可以看到詳細(xì)信息。 通過兩個對比,我們不難發(fā)現(xiàn) User-Agent 和 signKey 數(shù)據(jù)是變化的(平臺使用了數(shù)據(jù)加密) 所以我們需要對User-Agent與signKey分別進(jìn)行解密。 通

    2024年04月24日
    瀏覽(26)
  • 7個Pandas繪圖函數(shù)助力數(shù)據(jù)可視化

    7個Pandas繪圖函數(shù)助力數(shù)據(jù)可視化

    大家好,在使用Pandas分析數(shù)據(jù)時,會使用Pandas函數(shù)來過濾和轉(zhuǎn)換列,連接多個數(shù)據(jù)幀中的數(shù)據(jù)等操作。但是,生成圖表將數(shù)據(jù)在數(shù)據(jù)幀中可視化 , 通常比僅僅查看數(shù)字更有幫助。 Pandas具有幾個繪圖函數(shù),可以使用它們快速輕松地實(shí)現(xiàn)數(shù)據(jù)可視化,文中將介紹這些函數(shù)。 首先

    2024年01月21日
    瀏覽(48)
  • 計算機(jī)畢設(shè) 大數(shù)據(jù)上海租房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    計算機(jī)畢設(shè) 大數(shù)據(jù)上海租房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    # 1 前言 ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點(diǎn),往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項

    2024年02月07日
    瀏覽(27)
  • 計算機(jī)畢設(shè) 大數(shù)據(jù)二手房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    計算機(jī)畢設(shè) 大數(shù)據(jù)二手房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    # 1 前言 ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點(diǎn),往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項

    2024年02月04日
    瀏覽(30)
  • python畢設(shè)選題 - 大數(shù)據(jù)上海租房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    python畢設(shè)選題 - 大數(shù)據(jù)上海租房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    # 1 前言 ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點(diǎn),往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項

    2024年02月19日
    瀏覽(30)
  • python畢設(shè)選題 - 大數(shù)據(jù)二手房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    python畢設(shè)選題 - 大數(shù)據(jù)二手房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    # 1 前言 ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點(diǎn),往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項

    2024年01月20日
    瀏覽(29)
  • 大數(shù)據(jù)畢設(shè)分享 大數(shù)據(jù)二手房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    大數(shù)據(jù)畢設(shè)分享 大數(shù)據(jù)二手房數(shù)據(jù)爬取與分析可視化 -python 數(shù)據(jù)分析 可視化

    # 1 前言 ?? 這兩年開始畢業(yè)設(shè)計和畢業(yè)答辯的要求和難度不斷提升,傳統(tǒng)的畢設(shè)題目缺少創(chuàng)新和亮點(diǎn),往往達(dá)不到畢業(yè)答辯的要求,這兩年不斷有學(xué)弟學(xué)妹告訴學(xué)長自己做的項目系統(tǒng)達(dá)不到老師的要求。 為了大家能夠順利以及最少的精力通過畢設(shè),學(xué)長分享優(yōu)質(zhì)畢業(yè)設(shè)計項

    2024年01月23日
    瀏覽(34)
  • 用Python爬取電影數(shù)據(jù)并可視化分析

    用Python爬取電影數(shù)據(jù)并可視化分析

    ? ???♂? 個人主頁:@艾派森的個人主頁 ???作者簡介:Python學(xué)習(xí)者 ?? 希望大家多多支持,我們一起進(jìn)步!?? 如果文章對你有幫助的話, 歡迎評論 ??點(diǎn)贊???? 收藏 ??加關(guān)注+ 目錄 一、獲取數(shù)據(jù) 1.技術(shù)工具 2.爬取目標(biāo) 3.字段信息 二、數(shù)據(jù)預(yù)處理 1.加載數(shù)據(jù) 2.異常值

    2024年02月06日
    瀏覽(24)
  • pandas plot函數(shù):數(shù)據(jù)可視化的快捷通道

    pandas plot函數(shù):數(shù)據(jù)可視化的快捷通道

    一般來說,我們先用 pandas 分析數(shù)據(jù),然后用 matplotlib 之類的可視化庫來顯示分析結(jié)果。 而 pandas 庫中有一個強(qiáng)大的工具-- plot 函數(shù),可以使數(shù)據(jù)可視化變得簡單而高效。 plot 函數(shù)是 pandas 中用于數(shù)據(jù)可視化的一個重要工具, 通過 plot 函數(shù),可以輕松地將 DataFrame 或 Series 對象

    2024年03月09日
    瀏覽(36)
  • EDA-數(shù)據(jù)探索-pandas自帶可視化-iris

    sepal_length sepal_width petal_length petal_width species 0 5.1 3.5 1.4 0.2 setosa 1 4.9 3.0 1.4 0.2 setosa 2 4.7 3.2 1.3 0.2 setosa 3 4.6 3.1 1.5 0.2 setosa 4 5.0 3.6 1.4 0.2 setosa 條形圖(柱狀圖)展示每個字符特征的頻數(shù)分布。 df[‘字符特征’].value_counts().plot(kind=‘bar’) 直方圖展示數(shù)字特征的分布情況。 df[‘?dāng)?shù)

    2024年01月19日
    瀏覽(40)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包