(self, idx)
return func_lines
Generate main code lines for df.getitem
Generate main code lines for df.getitem
Generate main code lines for df . getitem
def df_getitem_bool_array_idx_main_codelines(self, idx):
    """Generate main code lines for df.getitem"""

    has_positional_index = isinstance(idx, PositionalIndexType)
    res_index_expr = 'taken_pos' if has_positional_index else 'self._index.take(taken_pos)'
    func_lines = [f'  length = len(self._index)',
                  f'  if length != len(idx):',
                  f'    raise ValueError("Item wrong length.")',
                  f'  taken_pos = getitem_by_mask(numpy.arange(length), idx)',
                  f'  res_index = {res_index_expr}'
                  ]
    results = []
    for i, col in enumerate(self.columns):
        col_loc = self.column_loc[col]
        type_id, col_id = col_loc.type_id, col_loc.col_id
        res_data = f'res_data_{i}'
        func_lines += [
            f'  data_{i} = self._data[{type_id}][{col_id}]',
            f'  {res_data} = sdc_take(data_{i}, taken_pos)'
        ]
        results.append((col, res_data))

    data = ', '.join(f'"{col}": {data}' for col, data in results)
    func_lines += [
        f'  return pandas.DataFrame({{{data}}}, index=res_index)'
    ]

    return func_lines
def df_getitem_bool_array_idx_main_codelines ( self , idx ) : has_positional_index = isinstance ( idx , PositionalIndexType ) res_index_expr = 'taken_pos' if has_positional_index else 'self._index.take(taken_pos)' func_lines = [ f'  length = len(self._index)' , f'  if length != len(idx):' , f'    raise ValueError("Item wrong length.")' , f'  taken_pos = getitem_by_mask(numpy.arange(length), idx)' , f'  res_index = {res_index_expr}' ] results = [ ] for i , col in enumerate ( self . columns ) : col_loc = self . column_loc [ col ] type_id , col_id = col_loc . type_id , col_loc . col_id res_data = f'res_data_{i}' func_lines += [ f'  data_{i} = self._data[{type_id}][{col_id}]' , f'  {res_data} = sdc_take(data_{i}, taken_pos)' ] results . append ( ( col , res_data ) ) data = ', ' . join ( f'"{col}": {data}' for col , data in results ) func_lines += [ f'  return pandas.DataFrame({{{data}}}, index=res_index)' ] return func_lines