(self, idx)
return func_text, global_vars
Example of generated implementation:
        def _df_getitem_single_label_loc_impl(self, idx):
          idx_list = find_idx(self._dataframe._index, idx)
          data_0 = sdc_take(self._dataframe._data[0][0], idx_list)
          res_data_0 = pandas.Series(data_0)
          data_1 = sdc_take(self._dataframe._data[1][0], idx_list)
          res_data_1 = pandas.Series(data_1)
          data_2 = sdc_take(self._dataframe._data[0][1], idx_list)
          res_data_2 = pandas.Series(data_2)
          if len(idx_list) < 1:
            raise KeyError('Index is not in the DataFrame')
          new_index = self._dataframe._index.take(idx_list)
          return pandas.DataFrame({"A": res_data_0, "B": res_data_1, "C": res_data_2}, index=new_index)
Example of generated implementation:
        def _df_getitem_single_label_loc_impl(self, idx):
          idx_list = find_idx(self._dataframe._index, idx)
          data_0 = sdc_take(self._dataframe._data[0][0], idx_list)
          res_data_0 = pandas.Series(data_0)
          data_1 = sdc_take(self._dataframe._data[1][0], idx_list)
          res_data_1 = pandas.Series(data_1)
          data_2 = sdc_take(self._dataframe._data[0][1], idx_list)
          res_data_2 = pandas.Series(data_2)
          if len(idx_list) < 1:
            raise KeyError('Index is not in the DataFrame')
          new_index = self._dataframe._index.take(idx_list)
          return pandas.DataFrame({"A": res_data_0, "B": res_data_1, "C": res_data_2}, index=new_index)
Example of generated implementation : def _df_getitem_single_label_loc_impl ( self idx ) : idx_list = find_idx ( self . _dataframe . _index idx ) data_0 = sdc_take ( self . _dataframe . _data [ 0 ] [ 0 ] idx_list ) res_data_0 = pandas . Series ( data_0 ) data_1 = sdc_take ( self . _dataframe . _data [ 1 ] [ 0 ] idx_list ) res_data_1 = pandas . Series ( data_1 ) data_2 = sdc_take ( self . _dataframe . _data [ 0 ] [ 1 ] idx_list ) res_data_2 = pandas . Series ( data_2 ) if len ( idx_list ) < 1 : raise KeyError ( Index is not in the DataFrame ) new_index = self . _dataframe . _index . take ( idx_list ) return pandas . DataFrame ( { A : res_data_0 B : res_data_1 C : res_data_2 } index = new_index )
def df_getitem_single_label_loc_codegen(self, idx):
    """
    Example of generated implementation:
        def _df_getitem_single_label_loc_impl(self, idx):
          idx_list = find_idx(self._dataframe._index, idx)
          data_0 = sdc_take(self._dataframe._data[0][0], idx_list)
          res_data_0 = pandas.Series(data_0)
          data_1 = sdc_take(self._dataframe._data[1][0], idx_list)
          res_data_1 = pandas.Series(data_1)
          data_2 = sdc_take(self._dataframe._data[0][1], idx_list)
          res_data_2 = pandas.Series(data_2)
          if len(idx_list) < 1:
            raise KeyError('Index is not in the DataFrame')
          new_index = self._dataframe._index.take(idx_list)
          return pandas.DataFrame({"A": res_data_0, "B": res_data_1, "C": res_data_2}, index=new_index)
    """
    if isinstance(self.index, PositionalIndexType):
        fill_list = ['  idx_list =  numpy.array([idx])']
        new_index = ['  new_index = numpy.array([idx])']

    else:
        fill_list = ['  idx_list = find_idx(self._dataframe._index, idx)']
        new_index = ['  new_index = self._dataframe._index.take(idx_list)']

    fill_list_text = '\n'.join(fill_list)
    new_index_text = '\n'.join(new_index)
    func_lines = ['def _df_getitem_single_label_loc_impl(self, idx):',
                  f'{fill_list_text}']
    results = []
    for i, c in enumerate(self.columns):
        col_loc = self.column_loc[c]
        type_id, col_id = col_loc.type_id, col_loc.col_id
        data = f'data_{i}'
        res_data = f'res_data_{i}'
        func_lines += [f'  {data} = sdc_take(self._dataframe._data[{type_id}][{col_id}], idx_list)',
                       f'  {res_data} = pandas.Series({data})']
        results.append((c, res_data))

    func_lines += ['  if len(idx_list) < 1:',
                   "    raise KeyError('Index is not in the DataFrame')"]

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

    func_text = '\n'.join(func_lines)
    global_vars = {'pandas': pandas, 'numpy': numpy,
                   'numba': numba,
                   'sdc_take': nplike_take,
                   'find_idx': find_idx,
                   'KeyError': KeyError}

    return func_text, global_vars
def df_getitem_single_label_loc_codegen ( self , idx ) : if isinstance ( self . index , PositionalIndexType ) : fill_list = [ '  idx_list =  numpy.array([idx])' ] new_index = [ '  new_index = numpy.array([idx])' ] else : fill_list = [ '  idx_list = find_idx(self._dataframe._index, idx)' ] new_index = [ '  new_index = self._dataframe._index.take(idx_list)' ] fill_list_text = '\n' . join ( fill_list ) new_index_text = '\n' . join ( new_index ) func_lines = [ 'def _df_getitem_single_label_loc_impl(self, idx):' , f'{fill_list_text}' ] results = [ ] for i , c in enumerate ( self . columns ) : col_loc = self . column_loc [ c ] type_id , col_id = col_loc . type_id , col_loc . col_id data = f'data_{i}' res_data = f'res_data_{i}' func_lines += [ f'  {data} = sdc_take(self._dataframe._data[{type_id}][{col_id}], idx_list)' , f'  {res_data} = pandas.Series({data})' ] results . append ( ( c , res_data ) ) func_lines += [ '  if len(idx_list) < 1:' , "    raise KeyError('Index is not in the DataFrame')" ] data = ', ' . join ( f'"{col}": {data}' for col , data in results ) func_lines += [ f'{new_index_text}' , f'  return pandas.DataFrame({{{data}}}, index=new_index)' ] func_text = '\n' . join ( func_lines ) global_vars = { 'pandas' : pandas , 'numpy' : numpy , 'numba' : numba , 'sdc_take' : nplike_take , 'find_idx' : find_idx , 'KeyError' : KeyError } return func_text , global_vars