double[,] sourceMatrix = source.ToMatrix(out columnNames);
double[][] inputs = sourceMatrix.GetColumns(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13).ToJagged();
基本上,double [,]是从Excel中获取的源矩阵。在这个例子中,我们在转换为二维数组时硬编码第1列到第13列。但是,如果要使用的列数是变量(可能是13,20,任何东西)怎么办 - 如何在不对要使用的每列的索引进行硬编码的情况下实现相同的转换,而只需指定范围或相似的东西?
答案 0 :(得分:0)
def parantes_in_parentList (row, df_list):
df_parent_list = df_list['parents_list'][df_list['student'] == row['student']]
if not df_parent_list.empty:
if row['contact_person'] in df_parent_list.iloc[0]:
return True
# return False in all the other case
return False
df1['bool'] = df1.apply(parantes_in_parentList , args=([df2]),axis=1)
可以动态生成参数