Python notes: each department's daily specials in April 2020

Leaders and colleagues:
Hello everyone!
 
The following is the details and summary information of each department of South China procurement center's "daily special purchase items" in April 2020.
Please pay more attention to and follow up with the heads of departments and categories.
Please refer to the attachment for details.
Thank you!
① From the observation and analysis of the following two figures, it can be seen that on April 5, the number of single products in discount storage was the most, 10; on April 6, the number of single products in discount storage was the least, 0. In April, an average of 3.03 items were discounted every day.
from pyecharts import options as opts
from pyecharts.charts import Map, Bar, Grid
from pyecharts.globals import ChartType, ThemeType
import random
# Add to
from pyecharts.charts import Line

date = ["4 January 1","4 February 2","4 March 3","4 April 4","4 May 5","4 June 6","4 July 7","4 August","4 September 9","4 October 10","4 November 11","4 December 12","4 13","4 14",
       "4 15th of","4 16","4 17","4 18","4 19","4 20","4 21","4 22","4 23","4 April 24","4 25","4 26","4 27",
        "4 28","4 29th of","4 30"]
data = [2,7,1,1,10,0,5,4,6,2,6,2,2,4,1,3,3,2,4,2,2,4,1,1,5,1,3,2,3,2]
bar = (Bar()
       .add_xaxis(date)
       .add_yaxis("Number of daily discounted stock in items", data)
       .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
       .set_global_opts(
            title_opts=opts.TitleOpts(title="Number of daily discounted stock in items")
        )
      )

line = (Line()
       .add_xaxis(date)
       .add_yaxis("Number of daily discounted stock in items", data, 
                  markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]))
       .set_global_opts(title_opts=opts.TitleOpts(title="Change in the number of daily discounts", pos_top="48%"))
      )

grid = (
        Grid()
        .add(bar, grid_opts=opts.GridOpts(pos_bottom="60%"))
        .add(line, grid_opts=opts.GridOpts(pos_top="60%"))
    )

grid.render_notebook()

# Guest list
from pyecharts.charts import Line
from pyecharts import options as opts


date2 = ["4 January 1","4 February 2","4 March 3","4 April 4","4 May 5","4 June 6","4 July 7","4 August","4 September 9","4 October 10","4 November 11","4 December 12","4 13","4 14",
       "4 15th of","4 16","4 17","4 18","4 19","4 20","4 21","4 22","4 23 / 06","4 Month 24","4 25","4 26","4 27",
        "4 28","4 29th of","4 30"]
data2 = [2,7,1,1,10,0,5,4,6,2,6,2,2,4,1,3,3,2,4,2,2,4,1,1,5,1,3,2,3,2]

line = (Line()
       .add_xaxis(date2)
       .add_yaxis("4 Monthly daily discount acceptance list", data2, 
                  is_smooth=True, 
                  markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(name="Maximum", 
                                                                             coord=[date2[4], data2[4]], value=data2[4])]))
         
        
       .set_global_opts(title_opts=opts.TitleOpts(title="Daily trend", subtitle="South China Procurement Center"))
      )

line.render_notebook()

② In April, vegetables were the most popular, followed by aquatic products, fruits and comprehensive products. The proportion of each department was 39.56%, 31.87%, 18.68% and 9.89%, respectively
 
from pyecharts.charts import Funnel
from pyecharts import options as opts

# Sample data
cate1 = ["Vegetables","Aquatic product","Fruits","comprehensive"]
data1 = [36,29,17,9]
"""
//Example funnel chart:
1. sort_Control sorting, default descending;
2. Label display location
"""
funnel = (Funnel()
          .add("Number of discount items", [list(z) for z in zip(cate1, data1)], 
               sort_='ascending',
               label_opts=opts.LabelOpts(position="inside"))
          .set_global_opts(title_opts=opts.TitleOpts(title="Discount item proportion of each department", subtitle="2020 April of"))
         )

funnel.render_notebook()

from pyecharts.charts import Pie
from pyecharts import options as opts

# Sample data
cate = ["Vegetables","Aquatic product","Fruits","comprehensive"]
data = [36,29,17,9]
pie = (Pie()
       .add('', [list(z) for z in zip(cate, data)],
            radius=["30%", "75%"],
            rosetype="radius")
       .set_global_opts(title_opts=opts.TitleOpts(title="Proportion of discount items in each department", subtitle="2020 April of"))
       .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {d}%"))
      )

pie.render_notebook()

③ "Imported qingti" was the most frequently discounted, followed by "Rushan fresh oyster (box)", with the quantity of 8 and 6 respectively;
The frequency interval of the number of items in the daily discount stock in is [0,8], basically 1-2 items are discounted stock in every day; the mode is 2, the median is 3.03, the maximum value is 8, the minimum value is 0, and the range is 8
from pyecharts.charts import Bar
from pyecharts import options as opts

# Sample data
goods = ["Import qingti","Fresh oysters in Rushan(box)","small clam","The lotus root","Hanger(box)","Sweet potato","Chinese Cabbage","Octopus larvae","Fresh chestnut in Yunnan",
         "Lipu Taro","Water tofu","Brown sugar steamed bread(4 A suit)","Local carrot","Fertile orange","Imported banana","sweet corn","Spring fish","Shrimp",
         "Shandong crystal Fuji","Cauliflower seedling","Sea bass","Imported fruit","chicken breast","Sand white","Xiaojingbao","Beef cattle","Wax gourd","Croaker",
         "Cabbage","Sturgeon","Sweet potato seedling","Garlic heart","Gouache","Potato","Chenghai pickle","Balsam pear","Oriental Melon","Mandarin fish","Huang Xinbai",
         "White mushroom(box)","Mussel ","Baby Cabbage(package)","Fresh egg with grain","Red onion"]
data3 = [8,6,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
bar = (Bar()
       .add_xaxis(goods)
       .add_yaxis("Discount times of each item", data3)
       .set_global_opts(title_opts=opts.TitleOpts(title="Discount times of each item", subtitle="2020 April of"))
       .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
       .reversal_axis()
      )

bar.render_notebook()
from pyecharts.charts import Bar
from pyecharts import options as opts

# Sample data
goods1 = ["Croaker","Cabbage","Sturgeon","Sweet potato seedling","Garlic heart","Gouache","Potato","Chenghai pickle","Balsam pear","Oriental Melon","Mandarin fish","Huang Xinbai",
          "White mushroom(box)","Mussel ","Baby Cabbage(package)","Grain fresh egg","Red onion","Octopus larvae","Fresh chestnut in Yunnan","Lipu Taro","Water tofu",
          "Brown sugar steamed bread(4 A suit)","Local carrot","Fertile orange","Imported banana","sweet corn","Spring fish","Shrimp","Shandong crystal Fuji","Cabbage seedling",
          "Sea bass","Imported fruit","chicken breast","Sand white","Xiaojingbao","Beef cattle","Wax gourd","small clam","The lotus root","Hanger(box)","Sweet potato",
          "Chinese Cabbage","Fresh oysters in Rushan(box)","Import qingti"]
data4 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,4,4,4,4,6,8]
bar = (Bar()
       .add_xaxis(goods1)
       .add_yaxis("Discount times of each item", data4)
       .set_global_opts(title_opts=opts.TitleOpts(title="Discount times of each item", subtitle="2020 April of"))
       .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
       .reversal_axis()
      )

bar.render_notebook()

④  [details of each department's daily discounted stock in items in April]

Tags: Big Data Spring

Posted on Mon, 04 May 2020 16:55:18 -0700 by ben.hornshaw