(df, other, _func_name, ignore_index_value, indexes_comparable, args)
return func_def, global_vars
Example of generated implementation:
    def sdc_pandas_dataframe_append_impl(df, other, ignore_index=False, verify_integrity=False, sort=None):
        len_df = len(df._data[0][0])
        len_other = len(other._data[0][0])
        new_col_0_data_df = df._data[0][0]
        new_col_0_data_other = other._data[0][0]
        new_col_0 = init_series(new_col_0_data_df).append(init_series(new_col_0_data_other))._data
        new_col_1_data_df = df._data[0][1]
        new_col_1_data_other = other._data[0][1]
        new_col_1 = init_series(new_col_1_data_df).append(init_series(new_col_1_data_other))._data
        return pandas.DataFrame({"A": new_col_0, "B": new_col_1})
Example of generated implementation:
    def sdc_pandas_dataframe_append_impl(df, other, ignore_index=False, verify_integrity=False, sort=None):
        len_df = len(df._data[0][0])
        len_other = len(other._data[0][0])
        new_col_0_data_df = df._data[0][0]
        new_col_0_data_other = other._data[0][0]
        new_col_0 = init_series(new_col_0_data_df).append(init_series(new_col_0_data_other))._data
        new_col_1_data_df = df._data[0][1]
        new_col_1_data_other = other._data[0][1]
        new_col_1 = init_series(new_col_1_data_df).append(init_series(new_col_1_data_other))._data
        return pandas.DataFrame({"A": new_col_0, "B": new_col_1})
Example of generated implementation : def sdc_pandas_dataframe_append_impl ( df other ignore_index = False verify_integrity = False sort = None ) : len_df = len ( df . _data [ 0 ] [ 0 ] ) len_other = len ( other . _data [ 0 ] [ 0 ] ) new_col_0_data_df = df . _data [ 0 ] [ 0 ] new_col_0_data_other = other . _data [ 0 ] [ 0 ] new_col_0 = init_series ( new_col_0_data_df ) . append ( init_series ( new_col_0_data_other )) . _data new_col_1_data_df = df . _data [ 0 ] [ 1 ] new_col_1_data_other = other . _data [ 0 ] [ 1 ] new_col_1 = init_series ( new_col_1_data_df ) . append ( init_series ( new_col_1_data_other )) . _data return pandas . DataFrame ( { A : new_col_0 B : new_col_1 } )
def sdc_pandas_dataframe_append_codegen(df, other, _func_name, ignore_index_value, indexes_comparable, args):
    """
    Example of generated implementation:
    def sdc_pandas_dataframe_append_impl(df, other, ignore_index=False, verify_integrity=False, sort=None):
        len_df = len(df._data[0][0])
        len_other = len(other._data[0][0])
        new_col_0_data_df = df._data[0][0]
        new_col_0_data_other = other._data[0][0]
        new_col_0 = init_series(new_col_0_data_df).append(init_series(new_col_0_data_other))._data
        new_col_1_data_df = df._data[0][1]
        new_col_1_data_other = other._data[0][1]
        new_col_1 = init_series(new_col_1_data_df).append(init_series(new_col_1_data_other))._data
        return pandas.DataFrame({"A": new_col_0, "B": new_col_1})
    """
    indent = 4 * ' '
    func_args = ['df', 'other'] + kwsparams2list(args)

    df_columns_indx = {col_name: i for i, col_name in enumerate(df.columns)}
    other_columns_indx = {col_name: i for i, col_name in enumerate(other.columns)}

    # Keep columns that are StringArrayType
    string_type_columns = set(col_name for typ, col_name in zip(df.data, df.columns)
                              if isinstance(typ, StringArrayType))

    for typ, col_name in zip(other.data, other.columns):
        if isinstance(typ, StringArrayType):
            string_type_columns.add(col_name)

    func_definition = [f'def sdc_pandas_dataframe_{_func_name}_impl({", ".join(func_args)}):']
    func_text = []
    column_list = []

    func_text.append(f'len_df = len(df._data[0][0])')
    func_text.append(f'len_other = len(other._data[0][0])')

    for col_name, idx in df_columns_indx.items():
        col_loc = df.column_loc[col_name]
        type_id, col_id = col_loc.type_id, col_loc.col_id
        func_text.append(f'new_col_{idx}_data_df = df._data[{type_id}][{col_id}]')
        if col_name in other_columns_indx:
            other_col_loc = other.column_loc[col_name]
            other_type_id, other_col_id = other_col_loc.type_id, other_col_loc.col_id
            func_text.append(f'new_col_{idx}_data_other = '
                             f'other._data[{other_type_id}][{other_col_id}]')
            s1 = f'pandas.Series(new_col_{idx}_data_df)'
            s2 = f'pandas.Series(new_col_{idx}_data_other)'
            func_text.append(f'new_col_{idx} = {s1}.append({s2})._data')
        else:
            func_text.append(f'new_col_{idx}_data = pandas.Series(new_col_{idx}_data_df)._data')
            if col_name in string_type_columns:
                func_text.append(f'new_col_{idx} = fill_str_array(new_col_{idx}_data, len_df+len_other)')
            else:
                func_text.append(f'new_col_{idx} = fill_array(new_col_{idx}_data, len_df+len_other)')
        column_list.append((f'new_col_{idx}', col_name))

    for col_name, idx in other_columns_indx.items():
        if col_name not in df_columns_indx:
            other_col_loc = other.column_loc[col_name]
            other_type_id, other_col_id = other_col_loc.type_id, other_col_loc.col_id
            func_text.append(f'new_col_{idx}_data_other = other._data[{other_type_id}][{other_col_id}]')
            func_text.append(f'new_col_{idx}_data = pandas.Series(new_col_{idx}_data_other)._data')
            if col_name in string_type_columns:
                func_text.append(
                    f'new_col_{idx}_other = '
                    f'fill_str_array(new_col_{idx}_data, len_df+len_other, push_back=False)')
            else:
                func_text.append(f'new_col_{idx}_other = '
                                 f'fill_array(new_col_{idx}_data, len_df+len_other, push_back=False)')
            column_list.append((f'new_col_{idx}_other', col_name))

    data = ', '.join(f'"{column_name}": {column}' for column, column_name in column_list)

    if ignore_index_value == True:  # noqa
        func_text.append(f'return pandas.DataFrame({{{data}}})\n')
    else:
        if indexes_comparable == False:  # noqa
            func_text.append(f'raise SDCLimitation("Indexes of dataframes are expected to have comparable '
                             f'(both Numeric or String) types if parameter ignore_index is set to False.")')
        else:
            func_text += [f'joined_index = df._index.append(other._index)\n',
                          f'return pandas.DataFrame({{{data}}}, index=joined_index)\n']

    func_definition.extend([indent + func_line for func_line in func_text])
    func_def = '\n'.join(func_definition)

    global_vars = {'pandas': pandas,
                   'fill_array': fill_array,
                   'fill_str_array': fill_str_array,
                   'SDCLimitation': SDCLimitation}

    return func_def, global_vars
def sdc_pandas_dataframe_append_codegen ( df , other , _func_name , ignore_index_value , indexes_comparable , args ) : indent = 4 * ' ' func_args = [ 'df' , 'other' ] + kwsparams2list ( args ) df_columns_indx = { col_name : i for i , col_name in enumerate ( df . columns ) } other_columns_indx = { col_name : i for i , col_name in enumerate ( other . columns ) } # Keep columns that are StringArrayType string_type_columns = set ( col_name for typ , col_name in zip ( df . data , df . columns ) if isinstance ( typ , StringArrayType ) ) for typ , col_name in zip ( other . data , other . columns ) : if isinstance ( typ , StringArrayType ) : string_type_columns . add ( col_name ) func_definition = [ f'def sdc_pandas_dataframe_{_func_name}_impl({", ".join(func_args)}):' ] func_text = [ ] column_list = [ ] func_text . append ( f'len_df = len(df._data[0][0])' ) func_text . append ( f'len_other = len(other._data[0][0])' ) for col_name , idx in df_columns_indx . items ( ) : col_loc = df . column_loc [ col_name ] type_id , col_id = col_loc . type_id , col_loc . col_id func_text . append ( f'new_col_{idx}_data_df = df._data[{type_id}][{col_id}]' ) if col_name in other_columns_indx : other_col_loc = other . column_loc [ col_name ] other_type_id , other_col_id = other_col_loc . type_id , other_col_loc . col_id func_text . append ( f'new_col_{idx}_data_other = ' f'other._data[{other_type_id}][{other_col_id}]' ) s1 = f'pandas.Series(new_col_{idx}_data_df)' s2 = f'pandas.Series(new_col_{idx}_data_other)' func_text . append ( f'new_col_{idx} = {s1}.append({s2})._data' ) else : func_text . append ( f'new_col_{idx}_data = pandas.Series(new_col_{idx}_data_df)._data' ) if col_name in string_type_columns : func_text . append ( f'new_col_{idx} = fill_str_array(new_col_{idx}_data, len_df+len_other)' ) else : func_text . append ( f'new_col_{idx} = fill_array(new_col_{idx}_data, len_df+len_other)' ) column_list . append ( ( f'new_col_{idx}' , col_name ) ) for col_name , idx in other_columns_indx . items ( ) : if col_name not in df_columns_indx : other_col_loc = other . column_loc [ col_name ] other_type_id , other_col_id = other_col_loc . type_id , other_col_loc . col_id func_text . append ( f'new_col_{idx}_data_other = other._data[{other_type_id}][{other_col_id}]' ) func_text . append ( f'new_col_{idx}_data = pandas.Series(new_col_{idx}_data_other)._data' ) if col_name in string_type_columns : func_text . append ( f'new_col_{idx}_other = ' f'fill_str_array(new_col_{idx}_data, len_df+len_other, push_back=False)' ) else : func_text . append ( f'new_col_{idx}_other = ' f'fill_array(new_col_{idx}_data, len_df+len_other, push_back=False)' ) column_list . append ( ( f'new_col_{idx}_other' , col_name ) ) data = ', ' . join ( f'"{column_name}": {column}' for column , column_name in column_list ) if ignore_index_value == True : # noqa func_text . append ( f'return pandas.DataFrame({{{data}}})\n' ) else : if indexes_comparable == False : # noqa func_text . append ( f'raise SDCLimitation("Indexes of dataframes are expected to have comparable ' f'(both Numeric or String) types if parameter ignore_index is set to False.")' ) else : func_text += [ f'joined_index = df._index.append(other._index)\n' , f'return pandas.DataFrame({{{data}}}, index=joined_index)\n' ] func_definition . extend ( [ indent + func_line for func_line in func_text ] ) func_def = '\n' . join ( func_definition ) global_vars = { 'pandas' : pandas , 'fill_array' : fill_array , 'fill_str_array' : fill_str_array , 'SDCLimitation' : SDCLimitation } return func_def , global_vars