数据例子Flsk&pyecharts动态数据可视化

文章资讯 2020-07-20 00:24:22

数据例子Flsk&pyecharts动态数据可视化

1.数据例子:
Film ,Major Studio,Budget
300,Warner Bros,
300,Warner Bros.,65
3:10 to Yuma,Lionsgate,48
30 Days of Night,Independent,32
Across the Universe,Independent,45
Alien vs. Predator -- Requiem,Fox,40
Alvin and the Chipmunks,Fox,70
American Gangster,Universal,10
Bee Movie,Paramount,15
Beowulf,Paramount,15
Blades of Glory,Paramount,61

2: 环境
pycharm新建Flask项目




3 数据处理:
Film ,Major Studio,Budget 为数据的三个标题 截断这三个数据就行
import pandas as pd
from threading import Timer
import math
# coding=utf-8
def getTotalData():
data1 = pd.read_csv('static/1.csv');
data2 = pd.read_csv('static/2.csv');
data3 = pd.read_csv('static/3.csv');
data4 = pd.read_csv('static/4.csv');
data5 = pd.read_csv('static/5.csv');
datadic1 = [];
datadic2 = [];
datadic3 = [];
datadic4 = [];
datadic5 = [];
# 处理数据.csv
for x, y in zip(data1['Major Studio'], data1['Budget']):
datadic1.append((x, y))
for x, y in zip(data2['Major Studio'], data2['Budget']):
datadic2.append((x, y))
for x, y in zip(data3['Lead Studio'], data3['Budget']):
datadic3.append((x, y))
for x, y in zip(data4['Lead Studio'], data4['Budget']):
datadic4.append((x, y))
for x, y in zip(data5['Lead Studio'], data5['Budget']):
datadic5.append((x, y))
totaldata = [];
totaldata.append(datadic1);
totaldata.append(datadic2);
totaldata.append(datadic3);
totaldata.append(datadic4);
totaldata.append(datadic5);
return totaldata;
indexx = 0;
curindex = 0;
end = 5;
returnData = dict();
# 定时处理数据
def dataPre():
global indexx, end, curindex, flag, returnData;
totalData = getTotalData(); # list[map]
# x = len(totalData[0]) + totalData[1].len() + totalData[2].len() + totalData[3].len() + totalData[4].len();
data = totalData[indexx];
# init
# print(curindex, end, indexx)
# print(len(data))
for k, v in data[curindex:end]:
if v == "nan" or math.isnan(v):# 截断 k v中 nan
continue;
if returnData.get(k, -1) == -1:
print(k, v);
returnData[k] = v;
else:
returnData[k] = returnData[k] + v;
print(len(returnData))
if end < len(data) - 20:
curindex = end;
end = end + 20;
if end >= len(data) - 20:
indexx += 1;
curindex = 0;
end = 20;
t = Timer(2, dataPre)
t.start()
print(returnData.keys(), end='n')
return returnData;
if __name__ == "__main__":
dataPre();