(func_name, func_params, series_params, df)
return func_text, global_vars
Example func_text for func_name='head' columns=('float', 'string'):
        def _df_head_impl(df, n=5):
          data_0 = df._data[0][0]
          series_0 = pandas.Series(data_0)
          result_0 = series_0.head(n=n)
          data_1 = df._data[1][0]
          series_1 = pandas.Series(data_1)
          result_1 = series_1.head(n=n)
          return pandas.DataFrame({"float": result_0, "string": result_1}, index=df._index[:n])
Example func_text for func_name='head' columns=('float', 'string'):
        def _df_head_impl(df, n=5):
          data_0 = df._data[0][0]
          series_0 = pandas.Series(data_0)
          result_0 = series_0.head(n=n)
          data_1 = df._data[1][0]
          series_1 = pandas.Series(data_1)
          result_1 = series_1.head(n=n)
          return pandas.DataFrame({"float": result_0, "string": result_1}, index=df._index[:n])
Example func_text for func_name = head columns = ( float string ) : def _df_head_impl ( df n = 5 ) : data_0 = df . _data [ 0 ] [ 0 ] series_0 = pandas . Series ( data_0 ) result_0 = series_0 . head ( n = n ) data_1 = df . _data [ 1 ] [ 0 ] series_1 = pandas . Series ( data_1 ) result_1 = series_1 . head ( n = n ) return pandas . DataFrame ( { float : result_0 string : result_1 } index = df . _index [ : n ] )
def _dataframe_reduce_columns_codegen_head(func_name, func_params, series_params, df):
    """
    Example func_text for func_name='head' columns=('float', 'string'):
        def _df_head_impl(df, n=5):
          data_0 = df._data[0][0]
          series_0 = pandas.Series(data_0)
          result_0 = series_0.head(n=n)
          data_1 = df._data[1][0]
          series_1 = pandas.Series(data_1)
          result_1 = series_1.head(n=n)
          return pandas.DataFrame({"float": result_0, "string": result_1}, index=df._index[:n])
    """
    results = []
    joined = ', '.join(func_params)
    func_lines = [f'def _df_{func_name}_impl(df, {joined}):']
    ind = 'index=df._index[:n]'
    for i, c in enumerate(df.columns):
        col_loc = df.column_loc[c]
        type_id, col_id = col_loc.type_id, col_loc.col_id
        result_c = f'result_{i}'
        func_lines += [f'  data_{i} = df._data[{type_id}][{col_id}]',
                       f'  series_{i} = pandas.Series(data_{i})',
                       f'  {result_c} = series_{i}.{func_name}({series_params})']
        results.append((df.columns[i], result_c))

    data = ', '.join(f'"{col}": {data}' for col, data in results)
    func_lines += [f'  return pandas.DataFrame({{{data}}}, {ind})']
    func_text = '\n'.join(func_lines)
    global_vars = {'pandas': pandas}

    return func_text, global_vars
def _dataframe_reduce_columns_codegen_head ( func_name , func_params , series_params , df ) : results = [ ] joined = ', ' . join ( func_params ) func_lines = [ f'def _df_{func_name}_impl(df, {joined}):' ] ind = 'index=df._index[:n]' for i , c in enumerate ( df . columns ) : col_loc = df . column_loc [ c ] type_id , col_id = col_loc . type_id , col_loc . col_id result_c = f'result_{i}' func_lines += [ f'  data_{i} = df._data[{type_id}][{col_id}]' , f'  series_{i} = pandas.Series(data_{i})' , f'  {result_c} = series_{i}.{func_name}({series_params})' ] results . append ( ( df . columns [ i ] , result_c ) ) data = ', ' . join ( f'"{col}": {data}' for col , data in results ) func_lines += [ f'  return pandas.DataFrame({{{data}}}, {ind})' ] func_text = '\n' . join ( func_lines ) global_vars = { 'pandas' : pandas } return func_text , global_vars