Import PANDAS AS PD DF = pd.DataFrame ({ 'ID' = [l, 2,3], 'the Name': [ 'Tim', 'Victor', 'Nick']}) to create an instance df.to_excel ( ' D : /Temp/output.xlsx ' ) to create a method Print ( ' Done! ' )
PANDAS AS pd Import
people = pd.read_excel ( 'D: /Temp/People.xlsx') # read People EXcel file
print (people.shape) #People number of files row
print (people.columns) # query column name
print (people .head (3)) # query first three lines
import pandas as pd people =pd.read_excel('D:/Temp/People.xlsx',header = None) #没有列名 people.columns = ['ID','Type','Title','Firstname','middlename','lastname'] #添加列名 print(people.columns)
import pandas as pd
people = pd.read_excel ( 'D: /Temp/People.xlsx', header = 1) # column name is not the first row, the second row is
people.set_index ( 'ID', inplace = True) # ID becomes the index index
Print (people.columns)
people.to_excel ( 'D: /Temp/output.xlsx') for the original file output Output File #
print('Done')
PD PANDAS AS Import DF = pd.read_excel ( 'D: /Temp/output.xlsx',index_col='ID') output from the step # Output the index index but although not without index_col = 'ID' or when generating Output will be more than an empty index. df.to_excel ( 'D: /Temp/output2.xlsx') Print ( 'Done @!')