

def rowmap(table, rowmapper, header, failonerror=False):
    "\n    Transform rows via an arbitrary function. E.g.::\n\n        >>> import petl as etl\n        >>> table1 = [['id', 'sex', 'age', 'height', 'weight'],\n        ...           [1, 'male', 16, 1.45, 62.0],\n        ...           [2, 'female', 19, 1.34, 55.4],\n        ...           [3, 'female', 17, 1.78, 74.4],\n        ...           [4, 'male', 21, 1.33, 45.2],\n        ...           [5, '-', 25, 1.65, 51.9]]\n        >>> def rowmapper(row):\n        ...     transmf = {'male': 'M', 'female': 'F'}\n        ...     return [row[0],\n        ...             transmf[row['sex']] if row['sex'] in transmf else None,\n        ...             row.age * 12,\n        ...             row.height / row.weight ** 2]\n        ...\n        >>> table2 = etl.rowmap(table1, rowmapper,\n        ...                     header=['subject_id', 'gender', 'age_months',\n        ...                             'bmi'])\n        >>> table2\n        +------------+--------+------------+-----------------------+\n        | subject_id | gender | age_months | bmi                   |\n        +============+========+============+=======================+\n        |          1 | 'M'    |        192 | 0.0003772112382934443 |\n        +------------+--------+------------+-----------------------+\n        |          2 | 'F'    |        228 | 0.0004366015456998006 |\n        +------------+--------+------------+-----------------------+\n        |          3 | 'F'    |        204 | 0.0003215689675106949 |\n        +------------+--------+------------+-----------------------+\n        |          4 | 'M'    |        252 | 0.0006509906805544679 |\n        +------------+--------+------------+-----------------------+\n        |          5 | None   |        300 | 0.0006125608384287258 |\n        +------------+--------+------------+-----------------------+\n\n    The `rowmapper` function should accept a single row and return a single\n    row (list or tuple).\n\n    "
    return RowMapView(rowmapper, rowmapper, header, failonerror=failonerror)

dataset/ETHPy150Open alimanfoo/petl/petl/transform/maps.py rowmap/VarMisuse@23/693 `table`->`rowmapper`