11/*-------------------------------------------------------------------------*
22 | DataFrame -› filtering · iloc() |
33 | |
4- | Выбор строк и колонок из DataFrame по целочисленным позициям. |
4+ | Selection of rows and columns from DataFrame by integer positions. |
55 | |
6- | df.iloc(5) → выбор строки с индексом 5 |
7- | df.iloc([1, 3, 5]) → выбор строк с указанными индексами |
8- | df.iloc(5, 2) → выбор значения в строке 5, колонке 2 |
9- | df.iloc([1, 3], [0, 2]) → выбор строк 1,3 и колонок 0,2 |
6+ | df.iloc(5) → select row with index 5 |
7+ | df.iloc([1, 3, 5]) → select rows with specified indices |
8+ | df.iloc(5, 2) → select value in row 5, column 2 |
9+ | df.iloc([1, 3], [0, 2]) → select rows 1,3 and columns 0,2 |
1010 *-------------------------------------------------------------------------*/
1111
1212/**
@@ -75,7 +75,10 @@ export function iloc(df, rowSelector = null, colSelector = null) {
7575 // Process column selector
7676 if ( colSelector === null || colSelector === undefined ) {
7777 // If selector is null, select all columns
78- selectedColumnIndices = Array . from ( { length : allColumns . length } , ( _ , i ) => i ) ;
78+ selectedColumnIndices = Array . from (
79+ { length : allColumns . length } ,
80+ ( _ , i ) => i ,
81+ ) ;
7982 } else if ( typeof colSelector === 'number' ) {
8083 // Single column index
8184 const idx = colSelector < 0 ? allColumns . length + colSelector : colSelector ;
@@ -118,16 +121,19 @@ export function iloc(df, rowSelector = null, colSelector = null) {
118121
119122 // Create a new DataFrame instance with the same options as the original
120123 const result = new df . constructor ( { } , df . _options ) ;
121-
124+
122125 // For each selected column, create a Series with the appropriate type
123126 for ( const col of selectedColumns ) {
124127 // Get the original column data to determine its type
125128 const originalColumn = df . _columns [ col ] ;
126129 const originalArray = originalColumn . vector . __data ;
127- const values = selectedIndices . map ( index => rows [ index ] [ col ] ) ;
128-
130+ const values = selectedIndices . map ( ( index ) => rows [ index ] [ col ] ) ;
131+
129132 // Preserve the array type if it's a typed array
130- if ( ArrayBuffer . isView ( originalArray ) && ! ( originalArray instanceof DataView ) ) {
133+ if (
134+ ArrayBuffer . isView ( originalArray ) &&
135+ ! ( originalArray instanceof DataView )
136+ ) {
131137 const TypedArrayConstructor = originalArray . constructor ;
132138 const typedValues = new TypedArrayConstructor ( values . length ) ;
133139 values . forEach ( ( value , i ) => {
@@ -137,15 +143,14 @@ export function iloc(df, rowSelector = null, colSelector = null) {
137143 } else {
138144 result . _columns [ col ] = createTypedSeries ( values , col , df ) ;
139145 }
140-
146+
141147 // Add to column order
142148 if ( ! result . _order . includes ( col ) ) {
143149 result . _order . push ( col ) ;
144150 }
145151 }
146-
152+
147153 return result ;
148154}
149155
150156// Export the method for the pool
151- export default { iloc } ;
0 commit comments