Skip to content

Commit e67241b

Browse files
authored
DOC: Clarify allowed values for on_bad_lines in read_csv (#58662)
* Clarify allowed values for on_bad_lines in read_csv Move the callable options out of the version added/changed tags and improve the flow. * typo space before colon * trim trailing whitespace
1 parent 6973ad5 commit e67241b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pandas/io/parsers/readers.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -408,30 +408,32 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
408408
documentation for more details.
409409
on_bad_lines : {{'error', 'warn', 'skip'}} or Callable, default 'error'
410410
Specifies what to do upon encountering a bad line (a line with too many fields).
411-
Allowed values are :
411+
Allowed values are:
412412
413413
- ``'error'``, raise an Exception when a bad line is encountered.
414414
- ``'warn'``, raise a warning when a bad line is encountered and skip that line.
415415
- ``'skip'``, skip bad lines without raising or warning when they are encountered.
416+
- Callable, function that will process a single bad line.
417+
- With ``engine='python'``, function with signature
418+
``(bad_line: list[str]) -> list[str] | None``.
419+
``bad_line`` is a list of strings split by the ``sep``.
420+
If the function returns ``None``, the bad line will be ignored.
421+
If the function returns a new ``list`` of strings with more elements than
422+
expected, a ``ParserWarning`` will be emitted while dropping extra elements.
423+
- With ``engine='pyarrow'``, function with signature
424+
as described in `pyarrow documentation
425+
<https://arrow.apache.org/docs/python/generated/pyarrow.csv.ParseOptions.html
426+
#pyarrow.csv.ParseOptions.invalid_row_handler>`_.
416427
417428
.. versionadded:: 1.3.0
418429
419430
.. versionadded:: 1.4.0
420431
421-
- Callable, function with signature
422-
``(bad_line: list[str]) -> list[str] | None`` that will process a single
423-
bad line. ``bad_line`` is a list of strings split by the ``sep``.
424-
If the function returns ``None``, the bad line will be ignored.
425-
If the function returns a new ``list`` of strings with more elements than
426-
expected, a ``ParserWarning`` will be emitted while dropping extra elements.
427-
Only supported when ``engine='python'``
432+
Callable
428433
429434
.. versionchanged:: 2.2.0
430435
431-
- Callable, function with signature
432-
as described in `pyarrow documentation
433-
<https://arrow.apache.org/docs/python/generated/pyarrow.csv.ParseOptions.html
434-
#pyarrow.csv.ParseOptions.invalid_row_handler>`_ when ``engine='pyarrow'``
436+
Callable for ``engine='pyarrow'``
435437
436438
delim_whitespace : bool, default False
437439
Specifies whether or not whitespace (e.g. ``' '`` or ``'\\t'``) will be

0 commit comments

Comments
 (0)