(func_name, func_args, df, drop_col_names)
return func_def, global_vars
Example of generated implementation:
        def sdc_pandas_dataframe_drop_impl(df, labels=None, axis=0, index=None, columns=None,
                                            level=None, inplace=False, errors="raise"):
            list_0 = df._data[0].copy()
            for col_id in old_scheme_drop_idxs_0[::-1]:
                list_0.pop(col_id)
            list_1 = df._data[1].copy()
            new_data = (list_1, list_0, )
            return init_dataframe_internal(new_data, df._index, df_type)
Example of generated implementation:
        def sdc_pandas_dataframe_drop_impl(df, labels=None, axis=0, index=None, columns=None,
                                            level=None, inplace=False, errors="raise"):
            list_0 = df._data[0].copy()
            for col_id in old_scheme_drop_idxs_0[::-1]:
                list_0.pop(col_id)
            list_1 = df._data[1].copy()
            new_data = (list_1, list_0, )
            return init_dataframe_internal(new_data, df._index, df_type)
Example of generated implementation : def sdc_pandas_dataframe_drop_impl ( df labels = None axis = 0 index = None columns = None level = None inplace = False errors = raise ) : list_0 = df . _data [ 0 ] . copy () for col_id in old_scheme_drop_idxs_0 [ :: - 1 ] : list_0 . pop ( col_id ) list_1 = df . _data [ 1 ] . copy () new_data = ( list_1 list_0 ) return init_dataframe_internal ( new_data df . _index df_type )
def sdc_pandas_dataframe_drop_codegen(func_name, func_args, df, drop_col_names):
    """
    Example of generated implementation:
        def sdc_pandas_dataframe_drop_impl(df, labels=None, axis=0, index=None, columns=None,
                                            level=None, inplace=False, errors="raise"):
            list_0 = df._data[0].copy()
            for col_id in old_scheme_drop_idxs_0[::-1]:
                list_0.pop(col_id)
            list_1 = df._data[1].copy()
            new_data = (list_1, list_0, )
            return init_dataframe_internal(new_data, df._index, df_type)
    """
    indent = 4 * ' '
    func_definition = [f'def {func_name}({", ".join(func_args)}):']
    func_text = []

    old_column_loc, old_data_typs_map, old_types_order = get_structure_maps(df.data, df.columns)

    new_data_typs = tuple(t for i, t in enumerate(df.data) if df.columns[i] not in drop_col_names)
    new_column_names = tuple(c for c in df.columns if c not in drop_col_names)
    new_column_loc, new_data_typs_map, new_types_order = get_structure_maps(new_data_typs, new_column_names)

    old_types_idxs_map = dict(zip(old_types_order, range(len(old_types_order))))
    reorder_scheme = tuple(old_types_idxs_map[t] for t in new_types_order)
    df_type = DataFrameType(new_data_typs, df.index, new_column_names, column_loc=new_column_loc)

    old_scheme_drop_idxs = []
    for i, k in enumerate(old_types_order):
        a = [j for j, x in enumerate(old_data_typs_map[k][1]) if df.columns[x] in drop_col_names]
        old_scheme_drop_idxs.append(tuple(a) or None)

    for label in drop_col_names:
        if label not in df.columns:
            func_text.append(f'if errors == "raise":')
            func_text.append(indent + f'raise ValueError("The label {label} is not found in the selected axis")')
            break

    old_ntypes = len(old_types_order)
    for type_id in range(old_ntypes):
        func_text.append(f'list_{type_id} = df._data[{type_id}].copy()')
        if old_scheme_drop_idxs[type_id]:
            func_text.append(f'for col_id in old_scheme_drop_idxs_{type_id}[::-1]:')
            func_text.append(indent + f'list_{type_id}.pop(col_id)')

    # in new df the order of array lists (i.e. types_order) can be different, so
    # making a new tuple of lists reorder as needed
    new_ntypes = len(new_types_order)
    data_lists_reordered = ', '.join(['list_' + str(reorder_scheme[i]) for i in range(new_ntypes)])
    data_val = '(' + data_lists_reordered + ', )' if new_ntypes > 0 else '()'

    data, index = 'new_data', 'df._index'
    func_text.append(f'{data} = {data_val}')
    func_text.append(f"return init_dataframe_internal({data}, {index}, df_type)\n")
    func_definition.extend([indent + func_line for func_line in func_text])
    func_def = '\n'.join(func_definition)

    global_vars = {
        'pandas': pandas,
        'init_dataframe_internal': init_dataframe_internal,
        'df_type': df_type
    }

    global_vars.update({f'old_scheme_drop_idxs_{i}': old_scheme_drop_idxs[i] for i in range(old_ntypes)})

    return func_def, global_vars
def sdc_pandas_dataframe_drop_codegen ( func_name , func_args , df , drop_col_names ) : indent = 4 * ' ' func_definition = [ f'def {func_name}({", ".join(func_args)}):' ] func_text = [ ] old_column_loc , old_data_typs_map , old_types_order = get_structure_maps ( df . data , df . columns ) new_data_typs = tuple ( t for i , t in enumerate ( df . data ) if df . columns [ i ] not in drop_col_names ) new_column_names = tuple ( c for c in df . columns if c not in drop_col_names ) new_column_loc , new_data_typs_map , new_types_order = get_structure_maps ( new_data_typs , new_column_names ) old_types_idxs_map = dict ( zip ( old_types_order , range ( len ( old_types_order ) ) ) ) reorder_scheme = tuple ( old_types_idxs_map [ t ] for t in new_types_order ) df_type = DataFrameType ( new_data_typs , df . index , new_column_names , column_loc = new_column_loc ) old_scheme_drop_idxs = [ ] for i , k in enumerate ( old_types_order ) : a = [ j for j , x in enumerate ( old_data_typs_map [ k ] [ 1 ] ) if df . columns [ x ] in drop_col_names ] old_scheme_drop_idxs . append ( tuple ( a ) or None ) for label in drop_col_names : if label not in df . columns : func_text . append ( f'if errors == "raise":' ) func_text . append ( indent + f'raise ValueError("The label {label} is not found in the selected axis")' ) break old_ntypes = len ( old_types_order ) for type_id in range ( old_ntypes ) : func_text . append ( f'list_{type_id} = df._data[{type_id}].copy()' ) if old_scheme_drop_idxs [ type_id ] : func_text . append ( f'for col_id in old_scheme_drop_idxs_{type_id}[::-1]:' ) func_text . append ( indent + f'list_{type_id}.pop(col_id)' ) # in new df the order of array lists (i.e. types_order) can be different, so # making a new tuple of lists reorder as needed new_ntypes = len ( new_types_order ) data_lists_reordered = ', ' . join ( [ 'list_' + str ( reorder_scheme [ i ] ) for i in range ( new_ntypes ) ] ) data_val = '(' + data_lists_reordered + ', )' if new_ntypes > 0 else '()' data , index = 'new_data' , 'df._index' func_text . append ( f'{data} = {data_val}' ) func_text . append ( f"return init_dataframe_internal({data}, {index}, df_type)\n" ) func_definition . extend ( [ indent + func_line for func_line in func_text ] ) func_def = '\n' . join ( func_definition ) global_vars = { 'pandas' : pandas , 'init_dataframe_internal' : init_dataframe_internal , 'df_type' : df_type } global_vars . update ( { f'old_scheme_drop_idxs_{i}' : old_scheme_drop_idxs [ i ] for i in range ( old_ntypes ) } ) return func_def , global_vars