|
|
|
@ -90,93 +90,93 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
import openpyxl
|
|
|
|
|
from openpyxl.chart import ScatterChart, BarChart, AreaChart, Reference
|
|
|
|
|
|
|
|
|
|
import openpyxl
|
|
|
|
|
from openpyxl.chart import ScatterChart, BarChart, AreaChart, Reference
|
|
|
|
|
|
|
|
|
|
# 读取Excel文件
|
|
|
|
|
wb = openpyxl.load_workbook('bilibili_videos.xlsx')
|
|
|
|
|
ws = wb.active
|
|
|
|
|
|
|
|
|
|
# 创建柱状图1
|
|
|
|
|
bar_chart1 = BarChart()
|
|
|
|
|
bar_chart1.title = "观众对于视频的认可度"
|
|
|
|
|
bar_chart1.y_axis.title = "Data"
|
|
|
|
|
bar_chart1.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图1数据
|
|
|
|
|
bar_data1 = Reference(ws, min_col=17, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories1 = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart1.add_data(bar_data1, titles_from_data=True)
|
|
|
|
|
bar_chart1.set_categories(bar_categories1)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图1到工作表
|
|
|
|
|
ws.add_chart(bar_chart1, "V1")
|
|
|
|
|
|
|
|
|
|
# 创建柱状图
|
|
|
|
|
bar_chart = BarChart()
|
|
|
|
|
bar_chart.title = "收益"
|
|
|
|
|
bar_chart.y_axis.title = "Data"
|
|
|
|
|
bar_chart.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图数据
|
|
|
|
|
bar_data = Reference(ws, min_col=18, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart.add_data(bar_data, titles_from_data=True)
|
|
|
|
|
bar_chart.set_categories(bar_categories)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图到工作表
|
|
|
|
|
ws.add_chart(bar_chart, "AD1")
|
|
|
|
|
|
|
|
|
|
# 创建面积图
|
|
|
|
|
area_chart = AreaChart()
|
|
|
|
|
area_chart.title = "视频实用性"
|
|
|
|
|
area_chart.y_axis.title = "Data"
|
|
|
|
|
area_chart.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置面积图数据
|
|
|
|
|
area_data = Reference(ws, min_col=19, min_row=2, max_row=ws.max_row)
|
|
|
|
|
area_categories = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
area_chart.add_data(area_data, titles_from_data=True)
|
|
|
|
|
area_chart.set_categories(area_categories)
|
|
|
|
|
|
|
|
|
|
# 添加面积图到工作表
|
|
|
|
|
ws.add_chart(area_chart, "AL1")
|
|
|
|
|
|
|
|
|
|
# 创建柱状图
|
|
|
|
|
bar_chart_2 = BarChart()
|
|
|
|
|
bar_chart_2.title = "视频惊艳程度"
|
|
|
|
|
bar_chart_2.y_axis.title = "Data"
|
|
|
|
|
bar_chart_2.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图数据
|
|
|
|
|
bar_data_2 = Reference(ws, min_col=20, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories_2 = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart_2.add_data(bar_data_2, titles_from_data=True)
|
|
|
|
|
bar_chart_2.set_categories(bar_categories_2)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图到工作表
|
|
|
|
|
ws.add_chart(bar_chart_2, "AT1")
|
|
|
|
|
|
|
|
|
|
# 创建柱状图
|
|
|
|
|
bar_chart_3 = BarChart()
|
|
|
|
|
bar_chart_3.title = "视频的互动性"
|
|
|
|
|
bar_chart_3.y_axis.title = "Data"
|
|
|
|
|
bar_chart_3.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图数据
|
|
|
|
|
bar_data_3 = Reference(ws, min_col=21, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories_3 = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart_3.add_data(bar_data_3, titles_from_data=True)
|
|
|
|
|
bar_chart_3.set_categories(bar_categories_3)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图到工作表
|
|
|
|
|
ws.add_chart(bar_chart_3, "BB1")
|
|
|
|
|
|
|
|
|
|
# 保存Excel文件
|
|
|
|
|
wb.save('bilibili_videos_with_charts.xlsx')
|
|
|
|
|
|
|
|
|
|
def write_english_texts(file_path, sheet_name, texts):
|
|
|
|
|
# 读取Excel文件
|
|
|
|
|
wb = openpyxl.load_workbook('bilibili_videos.xlsx')
|
|
|
|
|
ws = wb.active
|
|
|
|
|
|
|
|
|
|
# 创建柱状图1
|
|
|
|
|
bar_chart1 = BarChart()
|
|
|
|
|
bar_chart1.title = "观众对于视频的认可度"
|
|
|
|
|
bar_chart1.y_axis.title = "Data"
|
|
|
|
|
bar_chart1.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图1数据
|
|
|
|
|
bar_data1 = Reference(ws, min_col=17, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories1 = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart1.add_data(bar_data1, titles_from_data=True)
|
|
|
|
|
bar_chart1.set_categories(bar_categories1)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图1到工作表
|
|
|
|
|
ws.add_chart(bar_chart1, "V1")
|
|
|
|
|
|
|
|
|
|
# 创建柱状图
|
|
|
|
|
bar_chart = BarChart()
|
|
|
|
|
bar_chart.title = "收益"
|
|
|
|
|
bar_chart.y_axis.title = "Data"
|
|
|
|
|
bar_chart.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图数据
|
|
|
|
|
bar_data = Reference(ws, min_col=18, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart.add_data(bar_data, titles_from_data=True)
|
|
|
|
|
bar_chart.set_categories(bar_categories)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图到工作表
|
|
|
|
|
ws.add_chart(bar_chart, "AD1")
|
|
|
|
|
|
|
|
|
|
# 创建面积图
|
|
|
|
|
area_chart = AreaChart()
|
|
|
|
|
area_chart.title = "视频实用性"
|
|
|
|
|
area_chart.y_axis.title = "Data"
|
|
|
|
|
area_chart.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置面积图数据
|
|
|
|
|
area_data = Reference(ws, min_col=19, min_row=2, max_row=ws.max_row)
|
|
|
|
|
area_categories = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
area_chart.add_data(area_data, titles_from_data=True)
|
|
|
|
|
area_chart.set_categories(area_categories)
|
|
|
|
|
|
|
|
|
|
# 添加面积图到工作表
|
|
|
|
|
ws.add_chart(area_chart, "AL1")
|
|
|
|
|
|
|
|
|
|
# 创建柱状图
|
|
|
|
|
bar_chart_2 = BarChart()
|
|
|
|
|
bar_chart_2.title = "视频惊艳程度"
|
|
|
|
|
bar_chart_2.y_axis.title = "Data"
|
|
|
|
|
bar_chart_2.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图数据
|
|
|
|
|
bar_data_2 = Reference(ws, min_col=20, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories_2 = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart_2.add_data(bar_data_2, titles_from_data=True)
|
|
|
|
|
bar_chart_2.set_categories(bar_categories_2)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图到工作表
|
|
|
|
|
ws.add_chart(bar_chart_2, "AT1")
|
|
|
|
|
|
|
|
|
|
# 创建柱状图
|
|
|
|
|
bar_chart_3 = BarChart()
|
|
|
|
|
bar_chart_3.title = "视频的互动性"
|
|
|
|
|
bar_chart_3.y_axis.title = "Data"
|
|
|
|
|
bar_chart_3.x_axis.title = "Index"
|
|
|
|
|
|
|
|
|
|
# 设置柱状图数据
|
|
|
|
|
bar_data_3 = Reference(ws, min_col=21, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_categories_3 = Reference(ws, min_col=2, min_row=2, max_row=ws.max_row)
|
|
|
|
|
bar_chart_3.add_data(bar_data_3, titles_from_data=True)
|
|
|
|
|
bar_chart_3.set_categories(bar_categories_3)
|
|
|
|
|
|
|
|
|
|
# 添加柱状图到工作表
|
|
|
|
|
ws.add_chart(bar_chart_3, "BB1")
|
|
|
|
|
|
|
|
|
|
# 保存Excel文件
|
|
|
|
|
wb.save('bilibili_videos_with_charts.xlsx')
|
|
|
|
|
|
|
|
|
|
def write_english_texts(file_path, sheet_name, texts):
|
|
|
|
|
# 打开 Excel 文件
|
|
|
|
|
wb = openpyxl.load_workbook(file_path)
|
|
|
|
|
sheet = wb[sheet_name]
|
|
|
|
@ -200,6 +200,7 @@ english_texts = [
|
|
|
|
|
"interaction"
|
|
|
|
|
] # 要写入的英文文本列表
|
|
|
|
|
|
|
|
|
|
write_english_texts(file_path, sheet_name, english_texts)
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
write_english_texts(file_path, sheet_name, english_texts)
|
|
|
|
|
|
|
|
|
|
print("Data analysis chart written to the Excel file.")
|
|
|
|
|
print("Data analysis chart written to the Excel file.")
|