In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use Python data to analyze the promotion time of the supermarket". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Python data to analyze the promotion time of the supermarket".
Project goal
Analyze the recent operation data of the supermarket, through the analysis, we have an intuitive understanding of the recent operation of the supermarket.
1. Read data
The data is stored in a table, and we read it out with pandas
Import pandas as pddata=pd.read_csv ('supermarket operation data. CSV', encoding='gbk',parse_dates= ["closing time"]) data
two。 Analyze which categories of goods sell well.
First group the data by category ID, then sum the grouped sales volume, and finally reset the index with reset_index
Data_group=data.groupby ("category ID") ["sales volume"]. Sum (). Reset_index () data_group
To pick out the top 10 categories of goods sold, we can rank data_group by "sales volume" and take out the top 10
Data_group=data_group.sort_values (by= "sales", ascending=False) .head (10) data_group
3. Analyze which goods sell well.
The analysis logic is consistent with which categories of analysis, the code is as follows:
Data ['sales'] = data ['sales volume'] * data ['unit price'] data
4. Analyze the proportion of sales in different stores
First calculate the sales and add it to the data:
Data ['sales'] = data ['sales volume'] * data ['unit price'] data
Group according to the stores, and sum the turnover after the grouping:
Data_group=data.groupby ('store number') ['sales'] .sum (). Reset_index () data_group
Draw a pie chart as a percentage of sales:
From pyecharts import options as optsfrom pyecharts.charts import Piex=list (data_group ['Store number']) y=list (data_group ['sales']) pie = (Pie () .add (", [(iPowerj) for iGrainj in zip (xMague y)], radius= [" 30% "," 75% "], center= [" 50% "," 50% "], rosetype=" radius " Label_opts=opts.LabelOpts (is_show=False),) .set _ global_opts (title_opts=opts.TitleOpts (title= "percentage of store sales") .set _ series_opts (label_opts=opts.LabelOpts (formatter= "{b}: {d}")) pie.render_notebook ()
5. Analyze the peak period of supermarket passenger flow
It is necessary to understand the peak period of passenger flow, which can help supermarkets to determine the most appropriate time to carry out promotional activities.
First extract the number of hours from the date
Data ['hours'] = data ['closing time'] .map (lambda x:int (x.strftime ("% H") data
Remove the weight of hours and orders
Traffic=data [['hour', 'order ID']] .drop _ duplicates () traffic
Calculate the order quantity per hour
Traffic_count=traffic.groupby (hours) ["order ID"] .count () traffic_count
Draw a line chart:
Import pyecharts.options as optsfrom pyecharts.charts import Linex= [str (I) for i in list (range (6jue 22)] y=list (traffic_count) line= (Line () .add _ xaxis (xaxis_data=x) .add _ yaxis (series_name= "sales volume", y_axis=y, is_smooth=True) .set _ global_opts (title_opts=opts.TitleOpts (title= "different time sales line chart")) Yaxis_opts=opts.AxisOpts (axistick_opts=opts.AxisTickOpts (is_show=True), splitline_opts=opts.SplitLineOpts (is_show=True),),) line.render_notebook ()
From the above picture, we can find that the sales peak of the supermarket is from 8 to 10:00, and then there is a small peak from 17 to 19:00, so the promotion effect in these two periods will be better!
Thank you for your reading, the above is the content of "how to use Python data to analyze the promotion time of the supermarket". After the study of this article, I believe you have a deeper understanding of how to use Python data to analyze the promotion time of the supermarket. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.