回覆“書籍”即可獲贈Python從入門到進階共10本電子書
專欄作者:zch,經管專業研一在讀,Python數據分析及可視化愛好者。公衆號後臺回覆入羣,拉你進技術羣與大佬們近距離交流。
01
關於繪圖數據
02
地理可視化
import pandas
as pd
from pyecharts.charts
import Map
import pyecharts.options
as opts
frame = pd.read_csv(
'C:\\Users\\dell\\Desktop\\分省年度數據2.csv',encoding=
'GBK')
map = Map()
map.add(
"我國地區的GDP",frame[[
'地區',
'2019年']].values.tolist(),
"china")
map.set_global_opts(visualmap_opts=opts.VisualMapOpts(min_=
500,max_=
12000))
map.render(
"2019年全國各地區GDP.html")
geo.set_global_opts(visualmap_opts=opts.VisualMapOpts(
is_piecewise=
True,
pieces=[
{
"min":
0,
"max":
10000,
"label":
"1~10000",
"color":
"cyan"},
{
"min":
10001,
"max":
20000,
"label":
"10001~20000",
"color":
"yellow"},
{
"min":
20001,
"max":
50000,
"label":
"20001~50000",
"color":
"orange"},
{
"min":
50001,
"max":
80000,
"label":
"50001~80000",
"color":
"coral"},
{
"min":
80001,
"max":
120000,
"label":
"80001~120000",
"color":
"red"},
]
))
import pandas
as pd
from pyecharts
import options
as opts
from pyecharts.charts
import Map, Timeline
frame = pd.read_csv(
'C:\\Users\\dell\\Desktop\\分省年度數據2.csv',encoding=
'GBK')
tl = Timeline()
for i
in range(
2010,
2020):
map0 = (
Map()
.add(
"省份",frame[[
'地區',str(i)+
'年']].values.tolist(),
"china")
.set_global_opts(
title_opts=opts.TitleOpts(title=
"Map-{}年GDP(億元)".format(i)),
visualmap_opts=opts.VisualMapOpts(
is_piecewise=
True,
pieces=[
{
"min":
0,
"max":
10000,
"label":
"1~10000",
"color":
"cyan"},
{
"min":
10001,
"max":
20000,
"label":
"10001~20000",
"color":
"yellow"},
{
"min":
20001,
"max":
50000,
"label":
"20001~50000",
"color":
"orange"},
{
"min":
50001,
"max":
80000,
"label":
"50001~80000",
"color":
"coral"},
{
"min":
80001,
"max":
120000,
"label":
"80001~12000",
"color":
"red"},
] ),))
tl.add(map0,
"{}年".format(i))
tl.render(
"2010~2019年全國各地區GDP.html")
03
小結
------------------- End -------------------
往期精彩文章推薦:
歡迎大家點贊,留言,轉發,轉載,感謝大家的相伴與支持
想加入Python學習羣請在後臺回覆【入羣】
萬水千山總是情,點個【在看】行不行
/今日留言主題/
隨便說一兩句吧~
本文分享自微信公衆號 - Python爬蟲與數據挖掘(crawler_python)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。