# data_mid_test **Repository Path**: jiayingb/data_mid_test ## Basic Information - **Project Name**: data_mid_test - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-11-01 - **Last Updated**: 2024-10-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README mid_test

概述:随着经济的发展,中国国民的收入有所增加,人们的生活质量也随之提高。近年来,人们拥有汽车,喜欢自驾游。此报告用作分析2017年中国各省的国民收入与人民出行的关系

数据:2017年中国各省国民消费水平、民用汽车拥有量、公路旅客出行量

故事:旅游是社会生产力发展到一定阶段后的必然产物,反映了一个国家或地区的社会发展状况。随着经济的发展,中国国民的收入有所增加,人们的生活质量也随之提高。近年来,人们拥有汽车,喜欢自驾游。此报告用作分析2017年中国各省的国民收入与人民出行的关系

In [ ]:
import pandas as pd
import csv,os
df=pd.read_csv("Desktop\Consumption and Tourism.csv")
df
In [63]:
print(list(df.provinces))
['北京', '天津', '河北', '山西', '内蒙古', '辽宁', '吉林', '黑龙江', '上海', '江苏', '浙江', '安徽', '福建', '江西', '山东', '河南', '湖北', '湖南', '广东', '广西', '海南', '重庆', '四川', '贵州', '云南', '西藏', '陕西', '甘肃', '青海', '宁夏', '新疆']
In [64]:
print(list(df['consumption']))
[52912, 38975, 15893, 18132, 23909, 24866, 15083, 18859, 53617, 39796, 33851, 17141, 25969, 17290, 28353, 17842, 21642, 19418, 30762, 16064, 20939, 22927, 17920, 16349, 15831, 10990, 18485, 14203, 18020, 21058, 16736]
In [65]:
print(list(df['civil_cars']))
[563.1, 287.69, 1387.21, 591.98, 480.22, 727.08, 387.15, 435.32, 360.96, 1612.82, 1395.8, 708.93, 557.01, 465.9, 1929.55, 1274.45, 679.81, 683.19, 1894.22, 502.13, 113.21, 370.47, 990.3, 414.01, 622.66, 40.88, 549.51, 287.45, 99.57, 130.94, 363.15]
In [66]:
print(list(df['highway_visitors']))
[99.4, 72.83, 239.94, 150.36, 142.65, 298.85, 162.99, 177.07, 116.67, 746.89, 431.56, 407.11, 227.83, 277.29, 481.04, 736.62, 482.27, 526.6, 1129.53, 370.38, 77.51, 289.54, 521.29, 463.93, 308.27, 26.66, 289.15, 247.76, 49.77, 55.84, 157.57]
In [67]:
df.consumption.describe()
#  查看2017年国民消费水平状况
Out[67]:
count       31.000000
mean     23349.419355
std      10537.687592
min      10990.000000
25%      16938.500000
50%      18859.000000
75%      25417.500000
max      53617.000000
Name: consumption, dtype: float64

描述: 从第一个地图的数据可视化地图可以明显看出,2017年国民的消费水平居高的是东部沿海城市,呈现红色的,中部内陆地区呈现橙红色,西部地区呈现黄绿色,经济发展还有待提高。

In [68]:
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType
def geo_consumption() -> Geo:
    c = (
        Geo()
        .add_schema(maptype="china")
        .add("consumption/元", [list(z) for z in zip(df.provinces,df.consumption)])
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(
            visualmap_opts=opts.VisualMapOpts(min_=10000,max_=30000),
            title_opts=opts.TitleOpts(title="2017年国民消费水平"),
        )
    )
    return c
geo_consumption().render_notebook()
Out[68]:
In [69]:
df.civil_cars.describe()
#  查看2017年国民汽车拥有状况
Out[69]:
count      31.000000
mean      674.408710
std       507.767419
min        40.880000
25%       366.810000
50%       549.510000
75%       718.005000
max      1929.550000
Name: civil_cars, dtype: float64

描述:从数据可视化地图可以看出,中东部地区的颜色较为深色,与第一个可视化地图有相联系,尤其是广东、北京、上海等比较发达的城市,居民的消费水平与民用汽车拥有量成正比。

In [70]:
from pyecharts.faker import Faker

from pyecharts import options as opts
from pyecharts .charts import Map
from pyecharts.globals import ChartType,SymbolType
def map_china() -> Map:
    c = (
        Map()
        .add("汽车拥有量", [list(z) for z in zip(list(df.provinces),list(df['civil_cars']))], "china")
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(
            title_opts=opts.TitleOpts(title="Map_世界地图"),
            visualmap_opts=opts.VisualMapOpts(max_=1000),
        )
       
    )
    return c

map_china().render_notebook()
Out[70]:
In [104]:
消费水平=list(df['consumption'])
消费水平
Out[104]:
[52912,
 38975,
 15893,
 18132,
 23909,
 24866,
 15083,
 18859,
 53617,
 39796,
 33851,
 17141,
 25969,
 17290,
 28353,
 17842,
 21642,
 19418,
 30762,
 16064,
 20939,
 22927,
 17920,
 16349,
 15831,
 10990,
 18485,
 14203,
 18020,
 21058,
 16736]
In [105]:
汽车拥有量=list(df['civil_cars'])
汽车拥有量
Out[105]:
[563.1,
 287.69,
 1387.21,
 591.98,
 480.22,
 727.08,
 387.15,
 435.32,
 360.96,
 1612.82,
 1395.8,
 708.93,
 557.01,
 465.9,
 1929.55,
 1274.45,
 679.81,
 683.19,
 1894.22,
 502.13,
 113.21,
 370.47,
 990.3,
 414.01,
 622.66,
 40.88,
 549.51,
 287.45,
 99.57,
 130.94,
 363.15]
In [106]:
高速公路出行=list(df['highway_visitors'])
高速公路出行
Out[106]:
[99.4,
 72.83,
 239.94,
 150.36,
 142.65,
 298.85,
 162.99,
 177.07,
 116.67,
 746.89,
 431.56,
 407.11,
 227.83,
 277.29,
 481.04,
 736.62,
 482.27,
 526.6,
 1129.53,
 370.38,
 77.51,
 289.54,
 521.29,
 463.93,
 308.27,
 26.66,
 289.15,
 247.76,
 49.77,
 55.84,
 157.57]

描述:从上两个图抽出了较为明显的几个城市分析,汽车拥有量多的城市,并不是出行也多。

相反,从最后一个图看出来。消费水平较高的城市,反而会出行的数量高。

In [114]:
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar


def bar_base() -> Bar:
    c = (
        Bar()
        .add_xaxis((["广东", "北京", "上海","四川","浙江","河南","山东"]))
        .add_yaxis("汽车",汽车拥有量 )
        .add_yaxis("出行",高速公路出行)
        .set_global_opts(title_opts=opts.TitleOpts(title="汽车-出行对比图"))
    )
    return c
bar_base().render_notebook()
Out[114]:
In [110]:
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import EffectScatter
from pyecharts.globals import SymbolType


def consumption_base() -> EffectScatter:
    c = (
        EffectScatter()
        .add_xaxis(["广东", "北京", "上海","四川","浙江","河南","山东"])
        .add_yaxis("消费水平",消费水平)
        .set_global_opts(title_opts=opts.TitleOpts(title=""))
    )
    return c
consumption_base().render_notebook()
Out[110]:
In [ ]: