内蒙古包头数据大屏可视化代码数据免费分享,原版可视化大屏分享如图,可做毕设用,需要联系细节。可视化代码开源自取,放在百度网盘
Flask执行前后端交互。
##资源分享:
flask部分代码:
# -*- coding: utf-8 -*-
import json
import pandas as pd
import numpy as np
import demjson
import os
class MyEncoder(json.JSONEncoder):
def default(self, obj):
"""
只要检查到了是bytes类型的数据就把它转为str类型
:param obj:
:return:
"""
if isinstance(obj, bytes):
return str(obj, encoding='utf-8')
return json.JSONEncoder.default(self, obj)
def get_data():
dict_return = {}
# 处理好的文件路径
path = "./data/"
file = path + "内蒙古.csv"
data = pd.read_csv(file, encoding='utf-8')
tp = list(data[u'品种'])
area=list(data[u'批发市场'])
high_price = list(i.split('¥')[1] for i in data[u'最高价格'])
low_price = list(i.split('¥')[1] for i in data[u'最低价格'])
price = list(i.split('¥')[1] for i in data[u'日均价'])
# 以下为将处理好的数据加入字典
dict_return['area'] = area
dict_return['name'] = tp
dict_return['high_price'] = high_price
dict_return['price'] = price
dict_return['low_price'] = list(low_price)
# 图表
item = []
for i in range(0, len(low_price)):
item.append({'name':tp[i],'low_price': low_price[i],'high_price':high_price[i],'price':price[i]})
data_tb = json.dumps(item,cls=MyEncoder,ensure_ascii = False)
data_tb = demjson.decode(data_tb)
dict_return['data_tb'] = data_tb
return dict_return
print(get_data())
from flask import Flask, request, render_template
from getdata import get_data
app = Flask(__name__)
app.jinja_env.auto_reload = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
app = Flask(__name__, template_folder='templates')
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
code = request.form.get('name')
dict_return = get_data(code)
return render_template('index.html', dict_return = dict_return)
else:
dict_return = get_data()
dict_return = get_data()
return render_template('index.html', dict_return = dict_return)
if __name__ == '__main__':
app.run(debug=True, port=5050)
内蒙古数据部分展示
年份 2019年总产量(万吨) 2020年总产量(万吨) 2021年总产量(万吨) 2019年单位面积产量(千克/公顷) 2020年单位面积产量(千克/公顷) 2021年单位面积产量(千克/公顷)
粮 食 3652.6 3664.1 3840.3 5350 5362 5578 谷 物 3261.8 3281.6 3529.1 6354 6345 6334 稻 谷 136.2 123.1 115.3 8474 7655 7432 小 麦 182.7 170.8 157.2 3396 3566 3556 玉 米 2722.3 2742.7 2994.2 7209 7173 7121 豆 类 251.6 256.4 186.8 1805 1857 1792 大 豆 226.0 234.7 168.5 1899 1953 1887 薯 类 139.1 126.1 124.4 4643 4495 4601 油 料 228.7 217.3 213.9 2457 2389 2622 葵花籽 172.8 168.2 151.5 2938 2944 3129 油菜籽 39.0 28.3 32.2 1504 1151 1440 胡麻籽 5.9 4.8 4.5 1319 1281 1148 甜 菜 629.6 620.7 362.0 49420 48788 47553 棉 花 0.01 0.01 0.00 1507 1442 1583 麻 类 0.3 0.3 0.1 2150 3299 2057 蔬 菜 1090.8 1075.1 993.7 54400 54385 54623 瓜类(果用瓜) 230.2 191.9 136.6 38052 38602 37915 园林水果 50.2 46.8 54.3 5150 4759 5185
内蒙古包头数据分析可视化,可做毕设用,代码不方便发,详细百度网盘自取。