Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem of inventory rate of goods by Python

Shulou Source: shulou.com Published: 2022-05-31 13:12:45 10月01日 Update

This article introduces the relevant knowledge of "Python how to solve the problem of commodity distribution rate". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Available data are as follows:

Sales for each category (cls) for each store (shopid_branch)

Count the distribution rate of each category, i.e. the number of stores selling each category/the total number of stores

Find the total number of stores per year:

shopid_branch_count_year =b_brandsale.groupby(['year']).shopid_branch.nunique().reset_index()\.rename(columns={'shopid_branch':' total stores per year'})#.pivot('year','shopid_branch')

Find the number of stores selling each type of product

shopid_branch_count_year_cls = b_brandsale.groupby(['year','cls']).\ shopid_branch.nunique().reset_index().pivot('year','cls','shopid_branch').reset_index()

Merge the two results together

Find the proportion

for each in ['others ',' milk powder','services',' cotton','toys',' supply','paper',' nutrition','lathe',' complementary food']: #print(each) new_col = each + 'rate' puhuolv[new_col]= puhuolv[each]/puhuolv['total stores per year']

"Python how to solve the problem of commodity distribution rate" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Goods stores head stores questions content more knowledge practicality learning next two number category dilemma large category milk powder actual total situation data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi vpn Redmi Shulou Technology macOS