classmethod DataFrame.getRow()
用法
[行] = getRow({rowindices})
[行] = getRowByIndex(index)
說明
[row] = getRow({rowindices})
獲取由 rowindices 指示的行
[row] = getRowByIndex(index)
獲取指定的從零開始的索引指定的行
輸入參數
rowindices
索引值的元胞數組,基數
DataFrame.getNumIndices
index
所需行的從零開始的整數索引
輸出參數
row
包含DataFrame 的水平“slice” 的元胞數組
示例
通過指定索引及其在表中的序號來提取行
df = DataFrame(3, 'ORIGIN', 'DEST', 'MODE', 'time');
origins = {'London'; 'New York'; 'Milan'; 'London'; 'New York'; 'Milan'}
destinations = {'New York'; 'Milan'; 'London'; 'New York'; 'Milan'; 'London'}
df.setColumn('ORIGIN', origins);
df.setColumn('DEST', destinations);
df.setColumn('MODE', {'air';'air';'air'; 'normal';'normal';'normal'})
df.setColumn('time', [6,7,2,60,60,20]);
% The two statements below refer to the same row
row1 = df.getRow('London', 'New York', 'air');
row2 = df.getRowByIndex(1);
row1(4)
row2(4)
給出:
ans =
6
ans =
6
相關用法
- Matlab AMPL DataFrame.getNumRows用法及代碼示例
- Matlab AMPL DataFrame.getNumCols用法及代碼示例
- Matlab AMPL DataFrame.getNumIndices用法及代碼示例
- Matlab AMPL DataFrame.getColumn用法及代碼示例
- Matlab AMPL DataFrame.setMatrix用法及代碼示例
- Matlab AMPL DataFrame.setColumn用法及代碼示例
- Matlab AMPL DataFrame.addRow用法及代碼示例
- Matlab AMPL DataFrame.addColumn用法及代碼示例
- Matlab AMPL DataFrame.DataFrame用法及代碼示例
- Matlab AMPL DataFrame.setValue用法及代碼示例
- Matlab AMPL ConstraintInstance.lb用法及代碼示例
- Matlab AMPL ConstraintInstance.ub用法及代碼示例
- Matlab AMPL VariableInstance.ub用法及代碼示例
- Matlab AMPL Constraint.body用法及代碼示例
- Matlab AMPL Parameter.hasDefault用法及代碼示例
- Matlab AMPL SetInstance.contains用法及代碼示例
- Matlab AMPL Variable.getIntegrality用法及代碼示例
- Matlab AMPL ObjectiveInstance.value用法及代碼示例
- Matlab AMPL Parameter.set用法及代碼示例
- Matlab AMPL Tuple.Tuple用法及代碼示例
注:本文由純淨天空篩選整理自ampl.com大神的英文原創作品 getRow。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。