相关文章
毕业设计 大数据抖音短视频数据分析与可视化
2024-11-10 18:21

毕设帮助,选题指导,技术解答,欢迎打扰,见B站个人主页

毕业设计 大数据抖音短视频数据分析与可视化

https://space.bilibili.com/33886978

# 读取数据df = pd.read_csv('data.csv')df.head()

df.info()

print('去重前:',df.shape[0],'行数据')print('去重后:',df.drop_duplicates().shape[0],'行数据')

print(np.sum(df.isnull()))

df['date'] = df['date'].astype('datetime64[ns]')df['real_time'] = df['real_time'].astype('datetime64[ns]')df['uid'] = df['uid'].astype('str')df['user_city'] = df['user_city'].astype('str')df['user_city'] = df['user_city'].apply(lambda x:x[:-2])df['item_id'] = df['item_id'].astype('str')df['author_id'] = df['author_id'].astype('str')df['item_city'] = df['item_city'].astype('str')df['item_city'] = df['item_city'].apply(lambda x:x[:-2])df['music_id'] = df['music_id'].astype('str')df['music_id'] = df['music_id'].apply(lambda x:x[:-2])

df.info()

user_city_count = user_info.groupby(['user_city']).count().sort_values(by=['uid'],ascending=False)x1 = list(user_city_count.index)y1 = user_city_count['uid'].tolist()len(y1)

#柱形图代码chart = Bar()chart.add_xaxis(x1)chart.add_yaxis('地区使用人数', y1, color='#F6325A',                     itemstyle_opts={'barBorderRadius':[60, 60, 20, 20]},                      label_opts=opts.LabelOpts(position='top'))chart.set_global_opts(datazoom_opts=opts.DataZoomOpts(    range_start=0,range_end=5,orient='horizontal',type_='slider',is_zoom_lock=False,  pos_left='1%' ),    visualmap_opts=opts.VisualMapOpts(is_show = False,type_='opacity',range_opacity=[0.2, 1]),                     title_opts=opts.TitleOpts(title="不同地区用户数量分布图",pos_left='40%'),                     legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%'))chart.render_notebook()

h_num = round((df.groupby(['H']).count()['uid']/10000),1).to_list()h = list(df.groupby(['H']).count().index)

chart = Line()chart.add_xaxis(h)chart.add_yaxis('观看数/(万)',h_num, areastyle_opts=opts.AreaStyleOpts(color = '#1AF5EF',opacity=0.3),                                  itemstyle_opts=opts.ItemStyleOpts(color='black'),                                  label_opts=opts.LabelOpts(font_size=12))chart.set_global_opts(legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%'),                     title_opts=opts.TitleOpts(title="不时间观看数量分布图",pos_left='40%'),)chart.render_notebook()

left = df.groupby(['H']).sum()[['finish','like']]right = df.groupby(['H']).count()['uid']per = pd.concat([left,right],axis=1)per['finish_radio'] = round(per['finish']*100/per['uid'],2)per['like_radio'] = round(per['like']*100/per['uid'],2)x = list(df.groupby(['H']).count().index)y1 = per['finish_radio'].to_list()y2 = per['like_radio'].to_list()#建立一个基础的图形chart1 = Line()chart1.add_xaxis(x)chart1.add_yaxis('完播率/%',y1,is_smooth=True,label_opts=opts.LabelOpts(is_show=False),is_symbol_show = False,                                      linestyle_opts=opts.LineStyleOpts(color='#F6325A',opacity=.7,curve=0,width=2,type_= 'solid' ))chart1.set_global_opts(yaxis_opts =  opts.AxisOpts(min_=25,max_=45))chart1.extend_axis(yaxis=opts.AxisOpts(min_=0.4,max_=3))#叠加折线图chart2 = Line()   chart2.add_xaxis(x)chart2.add_yaxis('点赞率/%',y2,yaxis_index=1,is_smooth=True,label_opts=opts.LabelOpts(is_show=False),is_symbol_show = False,                                            linestyle_opts=opts.LineStyleOpts(color='#1AF5EF',opacity=.7,curve=0,width=2,type_= 'solid' ))chart1.overlap(chart2) chart1.set_global_opts(legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%'),                     title_opts=opts.TitleOpts(title="点赞/完播率分布图",pos_left='40%'),)chart1.render_notebook()

df['weekday'] = df['date'].dt.weekdayweek = df.groupby(['weekday']).count()['uid'].to_list()df_pair = [['周一', week[0]], ['周二', week[1]], ['周三', week[2]], ['周四', week[3]], ['周五', week[4]], ['周六', week[5]], ['周日', week[6]]]chart = Pie()chart.add('', df_pair,radius=['40%', '70%'],rosetype='radius',center=['45%', '50%'],label_opts=opts.LabelOpts(is_show=True,formatter = '{b}:{c}次'))chart.set_global_opts(visualmap_opts=[opts.VisualMapOpts(min_=200000,max_=300000,type_='color', range_color=['#1AF5EF', '#F6325A', '#000000'],is_show=True,pos_top='65%')],                      legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%',orient='vertical'),                     title_opts=opts.TitleOpts(title="一周内播放分布图",pos_left='35%'),)chart.render_notebook()

df.groupby(['channel']).count()['uid']

author_info = df.drop_duplicates(['author_id','item_city'])[['author_id','item_city']]author_info.info()author_city_count = author_info.groupby(['item_city']).count().sort_values(by=['author_id'],ascending=False)x1 = list(author_city_count.index)y1 = author_city_count['author_id'].tolist()df.drop_duplicates(['author_id']).shape[0]

chart = Bar()chart.add_xaxis(x1)chart.add_yaxis('地区创作者人数', y1, color='#F6325A',                     itemstyle_opts={'barBorderRadius':[60, 60, 20, 20]})chart.set_global_opts(datazoom_opts=opts.DataZoomOpts(    range_start=0,range_end=5,orient='horizontal',type_='slider',is_zoom_lock=False,  pos_left='1%' ),    visualmap_opts=opts.VisualMapOpts(is_show = False,type_='opacity',range_opacity=[0.2, 1]),                     legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%'),                     title_opts=opts.TitleOpts(title="不同城市创作者分布图",pos_left='40%'))chart.render_notebook()

time = df.drop_duplicates(['item_id'])[['item_id','duration_time']]time = time.groupby(['duration_time']).count()x1 = list(time.index)y1 = time['item_id'].tolist()

chart = Bar()chart.add_xaxis(x1)chart.add_yaxis('视频时长对应视频数', y1, color='#1AF5EF',                     itemstyle_opts={'barBorderRadius':[60, 60, 20, 20]},               label_opts=opts.LabelOpts(font_size=12,  color='black'))chart.set_global_opts(datazoom_opts=opts.DataZoomOpts(    range_start=0,range_end=50,orient='horizontal',type_='slider'),    visualmap_opts=opts.VisualMapOpts(max_=100000,min_=200,is_show = False,type_='opacity',range_opacity=[0.4, 1]),                     legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%'),                     title_opts=opts.TitleOpts(title="不同时长作品分布图",pos_left='40%'))chart.render_notebook()

like_per = 100*np.sum(df['like'])/len(df['like'])finish_per = 100*np.sum(df['finish'])/len(df['finish'])gauge = Gauge()gauge.add("",[("视频互动率", like_per),['完播率',finish_per]],detail_label_opts=opts.LabelOpts(is_show=False,font_size=18),                                  axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(                                      color=[(0.3, "#1AF5EF"), (0.7, "#F6325A"), (1, "#000000")],width=20)))gauge.render_notebook()

df_cor = df[['finish','like','duration_time','H']] # 只选取部分cor_table = df_cor.corr(method='spearman')cor_array = np.array(cor_table)cor_name = list(cor_table.columns)value = [[i, j, cor_array[i,j]] for i in [3,2,1,0] for j in [0,1,2,3]] heat = HeatMap()heat.add_xaxis(cor_name)heat.add_yaxis("",cor_name,value,label_opts=opts.LabelOpts(is_show=True, position="inside"))heat.set_global_opts(visualmap_opts=opts.VisualMapOpts(is_show=False, max_=0.08, range_color=["#1AF5EF", "#F6325A", "#000000"]))heat.render_notebook()

temp = df['date'].to_list()puv = df.groupby(['date']).agg({'uid':'nunique','item_id':'count'})uv = puv['uid'].to_list()pv = puv['item_id'].to_list()time = puv.index.to_list()chart1 = Line()chart1.add_xaxis(time)chart1.add_yaxis('uv',uv,is_smooth=True,label_opts=opts.LabelOpts(is_show=False),is_symbol_show = False,                linestyle_opts=opts.LineStyleOpts(color='#1AF5EF',opacity=.7,curve=0,width=2,type_= 'solid' ))chart1.add_yaxis('pv',pv,is_smooth=True,label_opts=opts.LabelOpts(is_show=False),is_symbol_show = False,                linestyle_opts=opts.LineStyleOpts(color='#F6325A',opacity=.7,curve=0,width=2,type_= 'solid' ))chart1.render_notebook()

lc = []for i in range(len(time)-7):    bef = set(list(df[df['date']==time[i]]['uid']))    aft = set(list(df[df['date']==time[i+7]]['uid']))    stay = bef&aft    per = round(100*len(stay)/len(bef),2)    lc.append(per)    lc1 = []for i in range(len(time)-1):    bef = set(list(df[df['date']==time[i]]['uid']))    aft = set(list(df[df['date']==time[i+1]]['uid']))    stay = bef&aft    per = round(100*len(stay)/len(bef),2)    lc1.append(per)x7 = time[0:-7]chart1 = Line()chart1.add_xaxis(x7)chart1.add_yaxis('七日留存率/%',lc,is_smooth=True,label_opts=opts.LabelOpts(is_show=False),is_symbol_show = False,                linestyle_opts=opts.LineStyleOpts(color='#F6325A',opacity=.7,curve=0,width=2,type_= 'solid' ))chart1.set_global_opts(legend_opts=opts.LegendOpts(pos_right='10%',pos_top='2%'),                     title_opts=opts.TitleOpts(title="用户留存率分布图",pos_left='40%'),)chart1.render_notebook()

df1 = df.groupby(['uid']).agg({'item_id':'count','like':'sum','finish':'sum'})df1['like_per'] = df1['like']/df1['item_id']df1['finish_per'] = df1['finish']/df1['item_id']ndf1 = np.array(df1[['item_id','like_per','finish_per']])#.shapekmeans_per_k = [KMeans(n_clusters=k).fit(ndf1) for k in range(1,8)]inertias = [model.inertia_ for model in kmeans_per_k]chart = Line(init_opts=opts.InitOpts(width='560px',height='300px'))chart.add_xaxis(range(1,8))chart.add_yaxis("",inertias,label_opts=opts.LabelOpts(is_show=False),                linestyle_opts=opts.LineStyleOpts(color='#F6325A',opacity=.7,curve=0,width=3,type_= 'solid' ))chart.render_notebook()

n_cluster = 4cluster = KMeans(n_clusters=n_cluster,random_state=0).fit(ndf1)y_pre = cluster.labels_ # 查看聚好的类from sklearn.metrics import silhouette_scorefrom sklearn.metrics import silhouette_samplessilhouette_score(ndf1,y_pre) n_cluster = 3cluster = KMeans(n_clusters=n_cluster,random_state=0).fit(ndf1)y_pre = cluster.labels_ # 查看聚好的类from sklearn.metrics import silhouette_scorefrom sklearn.metrics import silhouette_samplessilhouette_score(ndf1,y_pre)

c_ = [[],[],[]]c_[0] = [87.998,9.1615,39.92]c_[1] = [13.292,12.077,50.012]c_[2] = [275.011,8.125,28.751]bar = Bar(init_opts=opts.InitOpts(theme='macarons',width='1000px',height='400px')) # 添加分类(x轴)的数据bar.add_xaxis(['播放数','点赞率(千分之)','完播率(百分之)'])bar.add_yaxis('0', [round(i,2) for i in c_[0]], stack='stack0') bar.add_yaxis('1',[round(i,2) for i in c_[1]], stack='stack1') bar.add_yaxis('2',[round(i,2) for i in c_[2]], stack='stack2') bar.render_notebook()

毕设帮助,选题指导,技术解答,欢迎打扰,见B站个人主页

    以上就是本篇文章【毕业设计 大数据抖音短视频数据分析与可视化】的全部内容了,欢迎阅览 ! 文章地址:http://ktsh.xhstdz.com/news/5215.html 
     栏目首页      相关文章      动态      同类文章      热门文章      网站地图      返回首页 物流园资讯移动站 http://ktsh.xhstdz.com/mobile/ , 查看更多   
最新文章
百度收录平台排名 揭秘百度收录平台排名,优化策略助你领跑新媒体
在当今这个信息爆炸的时代,互联网已成为企业展示自我、吸引客户、拓展市场不可或缺的重要渠道而在浩瀚的网络海洋中,如何让自己
为什么要做海外推广方式
为什么要进行海外推广方式:探索国际化市场的关键路径一、引言在全球化和数字化迅猛发展的当下,企业的海外推广成为了进入国际市
99%亚马逊运营都不知道的“以图找同款”功能!
亚马逊已与各大社交媒体平台达成了合作,在社媒平台的分享按钮中,多了一个亚马逊图标。大家可以理解为:从社媒平台到亚马逊平台
如何通过百度网站链接提交提升企业在搜索引擎中的知名度与排名
目前,数字化新时代盛行之际,网络的广泛应用使得网站成为企业展现自身、招揽顾客及拓展市场的重要载体。然而,仅有网站并非万能
电脑磁盘分区格式GPT和MBR哪个好 电脑磁盘分区格式GPT和MBR对比【详解】
  最近不少用户在安装电脑的时候经常会安装新的电脑硬盘,在新的电脑硬盘安装的时候,电脑都会提示用户需要进行初始化磁盘,并
百度seo排名优化是什么?
在当今这个数字化和信息化的时代,搜索引擎已经成为人们获取信息、寻找服务的重要工具。百度,作为中国非常大的搜索引擎,其排名
永州SEO优化,企业品牌腾飞的关键策略
永州SEO推广排名,助力企业品牌崛起。通过优化关键词、提升网站质量、布局搜索引擎算法,提高企业网站在搜索引擎中的排名,吸引
百度新网站收录揭秘:内容质量决定速度,SEO优化引爆排名
百度新网站收录情况近期,公众重点关注了百度搜索引擎针对新型网站的收录状况。作为网站主与网络市场推广从业者,网站于搜索引擎
SEO营销咨询,企业互联网转型的高效秘籍
SEO营销咨询,企业互联网转型的得力助手!我们提供专业的SEO策略,提升网站排名,增强网络曝光,助力企业高效转型,抢占市场先机
电商seo做法 电商SEO优化实战技巧揭秘
电商SEO:解锁流量与转化的秘密武器在当今这个数字化时代,电子商务已成为全球经济不可或缺的一部分随着市场竞争的日益激烈,如
相关文章