In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "python how to split excel according to a column of content", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "python how to split excel according to a column of content" bar!
Use python to divide a column into multiple excel according to content
We often encounter at work, similar to the table in the following picture, the leader asks you to screen out each department and set up a separate excel according to the format of "Finance Department .xlsx". If the data is less, what if you are asked to split it in the middle of the night if the amount of data is large?
1. Source code:
Import pandas as pd df1 = pd.read_excel (rascal C:\ Users\ dell\ Desktop\ 123.xlsxxexamples) DataList = list (df1.groupby (['department])) for IN_DATA in DataList: IN_DATA [1] .to _ excel (' CGUSERGUSEUSUSGUserUserUserUserUserUserUserUserUserUserUserUserLTUserLTUSUSLUTER'+ str (IN_DATA [0]) + '.xlsx', sheet_name=IN_DATA [0], index=False)
2. Explanation:
The function of reading excel in pandas library is mainly used here, followed by sorting by department, and then a new table is established in turn.
Matters needing attention
Raster C:\ Users\ dell\ Desktop\ 123.xlsx' is the absolute path of my file, and the place where the final result is generated is' CJV _ account'. The slash of the two paths is different because it has been said in the penetration that the difference between win system and linux system only needs to be converted by adding a r. Second, groupby (['department'] according to the title of the column in which the table is built separately according to your needs.
Thank you for reading, the above is the content of "python how to split excel according to a column of content". After the study of this article, I believe you have a deeper understanding of how python can split excel according to a column of content, and the specific use needs to be verified in practice. 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.