0
我在稱爲RateMatrix1的Excel文件中的不同模型和初始值存儲在不同的工作表中。我的模型是WIN,WSW,WPA,WFR ......並且我的初始值是WI,WS,WP,WF ...並且Excel上的表單也完全如此命名。使用電子表格名稱作爲熊貓的變量
現在,我想寫一個函數,它使用模型的名稱和initialValues作爲下面的「sheetnames」。我想知道在Python中是否有這樣做的方法。
import pandas as pd
import numpy as np
def MLA(model, initialValues)
RMatrix=(pd.read_excel("C:\Anaconda3\RateMatrix1.xlsx", sheetname="model", skiprows=0)).as_matrix() #read the matrix values from excel spreadsheet, and converts the values to a matrix
initialAmount = (pd.read_excel("C:\Anaconda3\RateMatrix1.xlsx", sheetname="initialValues", skiprows=0)).as_matrix() #read the column matrix (initial values) from excel spreadsheet, and converts the values to a matrix
return np.dot(RMatrix,initialAmount)
print(MLA(WIN,WI))
非常感謝您的幫助。