干代碼就完了:佟守伸!
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
plt.rcParams['font.sans-serif']=['SimHei']#提前設置字體跟匆,以便可以顯示中文
df = pd.read_csv('D:/Womens Clothing E-Commerce Reviews.csv') #這里不添加 index_col = 0/1/2 ~ ~ ~ 炒辉,自動添加索引
# df.info() #顯示表信息栏尚,可查看是否存在缺失值
# print(df.head()) #.tail() #要用print()才能看到結果宠默;head()默認前5行
# print(df.describe()) #各字段的描述統(tǒng)計分析
# df = df.dropna() #去除缺失值
# plt.hist(df['Age'],color='blue',label='Age') #直方圖
# plt.legend() #負責圖例是否顯示
# plt.xlabel('Age')
# plt.ylabel('Count')
# plt.title('Age distribution')
# plt.show()
# plt.figure(figsize=(10,8)) #不限定畫幅大小也可以出圖
# sns.boxplot(x='Rating',y='Age',data=df)
# plt.show()
# print(df['Class Name'].unique()) #去重
# rd = df[df['Recommended IND'] == 1]
# nrd = df[df['Recommended IND'] == 0]
# print(rd.head())
# plt.xticks(rotation=45)
# plt.hist(rd['Department Name'],color='blue',alpha=0.5,label='rd')
# plt.hist(nrd['Department Name'],color='red',alpha=0.1,label='nrd')#alpha越小越透明
# plt.legend()
# plt.title('你最騷')#前面設置了字體。才會正常顯示运怖,不設置的話就會亂碼
# plt.show()
df['Review Length'] = df['Review Text'].astype(str).apply(len) #新增了一列拼弃,apply()的用法可百度干一下
# print(df.head())
ax = sns.distplot(df['Review Length'], color="blue") #不加ax = 也行,ax是啥自行干
plt.title("Length of Reviews")
plt.show()
最后編輯于 :
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者