DataSource. Py (using jupyter notebook to create, save as py)
The import OS
The import pandas as pd
Def GetExcel (fullName, sheetName) :
If OS. Path. The exists (fullName) and OS. Path. Isfile (fullName) :
XLS=pd. ExcelFile (fullName) # open the excel file
Sheettab=XLS. Parse (sheetName) # open the specified sheet page
XLS. Close # close excel file
Return sheettab
The else:
Print (' files' + fullName, 'no')
======================================================
Another notebook code in the
The import pandas as pd
The import seaborn as SNS
Import the DataSource as DS # run here right
The file='./index/files/project plan. XLSX '
Price=pd. DataFrame (DS) GetExcel (file, 'outsourcing manpower price))
Print (type (price)
Newcolname={' expert ':' level ', 'year package (m) :' dprice} # set an old and new name mapping dictionary
Price. Rename (columns=newcolname, inplace=True) # field rename
# print (' B 'price. Shape)
Price=price. Dropna (subset=[' level ', 'dprice], how=' any ') # delete specified field is empty of all lines
# print (' A ', price. Shape)
================================
Problem: this two pieces of code in a notebook that executes no problem, but after the split, price=pd. The DataFrame (DS) GetExcel (file, 'outsourcing manpower price)) get the function return value