In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 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 split Excel files in batches in Python". 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 split Excel files in batches in Python".
Business requirements
The company's operation department needs to count the moving sales data of all relevant suppliers from January 1 to September 30 of this year.
The original table exported from the database totaled 44857 pieces of data.
Because of the large amount of data and the different quantity of goods sold by different suppliers, it is impossible to split the table with a fixed number of rows.
It is necessary to split different suppliers into independent sub-tables for commodity moving sales analysis.
The following figure shows the result of the split, with each supplier producing a separate Excel file:
The split child table contains moving sales data owned by a single independent supplier:
Implementation of Python code 1. Read the original Excel file
The first few lines of routine, there is nothing to explain, write with your eyes closed
Yes, such a simple thing has to be forced to show that we are different.
Import pandas as pd
Filepath = rust C:\ Users\ 33589\ Desktop\ non-tobacco sales data summary .xlsx'
Df = pd.read_excel (filepath) 2. List of suppliers after taking out the weight
The next line: through the unique function, get the name list of the target classification filter (inner So easy! )
Class_list = list (df ['supplier'] .unique ())
Class_list 3. Output Excel files for each supplier
Through the for loop + Boolean value, let the system automatically filter rows with the same name, and save them! Got it!
For i in class_list:
Df_cut = df [df ["supplier"] = = I]
Df_cut.to_excel (ringing.\% s.xlsxx% (I), encoding = 'utf-8') Thank you for your reading, the above is the content of "how to split Excel files in batch in Python". After the study of this article, I believe you have a deeper understanding of how to split Excel files in batches in Python. 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.