How to use Python Improve your work efficiency , Let's share this with you today .
We often use pandas Read in read write excel file , I often meet a excel There are multiple in the file sheet file , This is the time , You need to read multiple at once sheet And do corresponding data analysis or data processing , Finally, write a new excel file ( There are also many sheet). This article introduces several sheet Read in the file and write it to the new file after processing the data excel file ( Multiple sheet) Operation process .
Python Exchange of learning Q Group :660193417####
The excel In file 4 individual sheet( Sometimes how many sheet Don't know ), Now read in all sheet form .
import pandas as pd
df=pd.read_excel(' input data 123.xlsx',sheet_name=None)# Read excel all sheet data
df
all sheet The contents of are read into df in .
View all sheet name
df.keys()
View a sheet
At every sheet Add a new column
for i in df.keys():
df[i][' month ']=df[i][' Fill in the date '].astype(str).apply(lambda x:int(x[5:7]))
df
Multiple copies of data are written into one excel file ( Multiple sheet)(https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)
Now write the following four copies of data into a excel The difference of documents sheet in .
writer1 = pd.ExcelWriter(' Output data 0401.xlsx',engine='xlsxwriter')
for i in df.keys():
df[i].to_excel(writer1, sheet_name=i, index=False)
worksheet1 = writer1.sheets[i]
#worksheet1.set_column(1, 1, 150)# Set the width of the column
writer1.close()
This is the end of today's sharing , I hope this article can help you , If you like it, you can order a like .
Python Superior flexibility and ease of use make it one of the most popular programming languages , Especially for data scientists . This is largely due to the use of Python Dealing with large data sets is a simple thing . Now , Every technology company is developing a data strategy . ...
In the future, it will be regulated import os import codecs filenames=os.listdir(os.getcwd()) out=file("name.txt",& ...
import requestsfrom bs4 import BeautifulSoupimport csv date = open('test.csv', 'w')writer = csv.writ ...
One . python The code to open the file is as follows : f = open("d:\test.txt", "w") explain : The first parameter is the file name , Including paths : The second parameter is open mode mo ...
[ turn ] use Python Reading and writing Excel file from :http://www.gocalf.com/blog/python-read-write-excel.html#xlrd-xlwt Although I communicate with data every day ...
http://www.cnblogs.com/lovebread/archive/2009/12/24/1631108.html [Python] How to read and write files http://www.cnblogs.c ...
This article mainly introduces python File read and write, file directory and folder operation implementation code , Friends in need can refer to For safety's sake , It's best to give the open file object a name , In this way, the file can be closed quickly after the operation is completed , Prevent some useless ...
Python Reading and writing files are widely used in computer language , If you want to know the application , The following article will give you a detailed introduction to the relevant content , It will help you in the future learning process , Now let's introduce its application in detail . One . Open file Pytho ...
One . python The code to open the file is as follows : f = open("d:\test.txt", "w") explain : The first parameter is the file name , Including paths : The second parameter is open mode ...
Python Read and write files 1.open Use open Remember to call the file object after opening the file close() Method . For example, you can use try/finally Statement to ensure that the file can be closed at the end . file_object = open('t ...
As a family IT The company's CEO, I am very glad to communicate with you through blog . On the one hand, I can record my growth path in the form of blog , On the other hand, I can make friends with you , Communicate with everyone about the knowledge and experience of the company's management . First , The author is in 200 ...
1. First, judge the outer layer ,A .B.C.D All meet the requirements 2. Then look at the inner layer A :int i=0;i<5;i++ When i=1 when ; Into the second inner loop int j=0;j<Math.abs(i)*2+1 ...
<!doctype html><html lang="en"> <head> <meta charset="UTF-8" ...
Learn from here Initial #!/usr/bin/python2.7 #MAGIC_STRING_skd83749872 import os import __main__ imp ...
Baidu search , The following one is quite complete . FROM Pegasus923 http://www.cnblogs.com/pegasus923/archive/2011/01/26/1944838.html ...
brief introduction This blog will explain in detail mysql Some of the common sql Statement operation , For example, creating a database , Delete database , Create table , Modify table , Delete table , And simple query cases . About mysql In the data SQL The case of 1. Case insensitive 1. s ...
reference :http://blog.51cto.com/13769225/2121431 For indicators, please refer to the figure below : 1. Take the interface description ( Appoint VLAN Number ) command :snmpwalk -v 2c -c Cvicse12 ...
This is very detailed : Sharing Code between Windows Phone 8 and Windows 8 Applications http://msdn.microsoft.com/ ...
download ESXI Visit the official website https://www.vmware.com To download, choice vsphere download esxi https://my.vmware.com/en/group/vmware/ ...
You need to call the operating system shell When ordered ,Ruby It provides us with six ways to complete the task : 1.Exec Method : Kernel#exec Method replaces the current process by calling the specified command : Example : $ ...