{"record":{"id":"c614f4327b9f9ffe","repo":"apache/beam","slug":"nrows-not-yet-supported","errorCode":null,"errorMessage":"nrows not yet supported","messagePattern":"nrows not yet supported","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/io.py","lineNumber":95,"sourceCode":"      to false or leave it unspecified.\n      \"\"\"\n  if table is None:\n    raise ValueError(\"Please specify a BigQuery table to read from.\")\n  elif len(kwargs) > 0:\n    raise ValueError(\n        f\"Encountered unsupported parameter(s) in read_gbq: {kwargs.keys()!r}\"\n        \"\")\n  return _ReadGbq(table, dataset, project_id, use_bqstorage_api)\n\n\n@frame_base.with_docs_from(pd)\ndef read_csv(path, *args, splittable=False, binary=True, **kwargs):\n  \"\"\"If your files are large and records do not contain quoted newlines, you may\n  pass the extra argument ``splittable=True`` to enable dynamic splitting for\n  this read on newlines. Using this option for records that do contain quoted\n  newlines may result in partial records and data corruption.\"\"\"\n  if 'nrows' in kwargs:\n    raise ValueError('nrows not yet supported')\n  filename_column = kwargs.pop('filename_column', None)\n  return _ReadFromPandas(\n      pd.read_csv,\n      path,\n      args,\n      kwargs,\n      incremental=True,\n      binary=binary,\n      splitter=_TextFileSplitter(args, kwargs) if splittable else None,\n      filename_column=filename_column)\n\n\ndef _as_pc(df, label=None):\n  from apache_beam.dataframe import convert  # avoid circular import\n\n  # TODO(roberwb): Amortize the computation for multiple writes?\n  return convert.to_pcollection(df, yield_elements='pandas', label=label)\n","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/io.py#L77-L113","documentation":"In the Beam DataFrame API's read_csv, the nrows parameter is not implemented: passing it raises this guard error at call time. The deferred CSV reader supports streaming/splittable reads but not the row-limit option; read the data and use head()/limit downstream instead.","triggerScenarios":"Calling beam.dataframe.io.read_csv('f.csv', nrows=100) or forwarding a kwargs dict that contains nrows from a shared pandas configuration.","commonSituations":"Reusing pandas read_csv exploration code for sampling/head-of-file reads in a Beam pipeline; a shared kwargs dict built for pandas passed unchanged to Beam.","solutions":["Remove nrows and read the whole file (or a narrower file path).","Sample after the read: read then use .head(n) or .limit via Beam transforms.","If you only need a preview, read the file with plain pandas instead of Beam."],"exampleFix":"// before\ndf = read_csv('data.csv', nrows=1000)\n// after\ndf = read_csv('data.csv')\ndf = df.head(1000)  # or apply a limit downstream","handlingStrategy":"validation","validationCode":"if 'nrows' in kwargs:\n    del kwargs['nrows']  # or sample downstream instead","typeGuard":null,"tryCatchPattern":"try:\n    df = read_csv(path, **kwargs)\nexcept ValueError as e:\n    if 'nrows' in str(e):\n        kwargs.pop('nrows', None)\n        df = read_csv(path, **kwargs).head(nrows)\n    else:\n        raise","preventionTips":["Strip pandas-only kwargs before calling Beam dataframe IO","Sample with downstream .head() instead of nrows","Keep separate kwarg dicts for pandas vs Beam paths"],"tags":["python","apache-beam","dataframe","io"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}