Skip to content

fix(csv): correct to_csv quoting documentation and expose QUOTE_NONE#21517

Open
a-hirota wants to merge 4 commits into
rapidsai:mainfrom
a-hirota:feature/csv-quoting-none-upstream
Open

fix(csv): correct to_csv quoting documentation and expose QUOTE_NONE#21517
a-hirota wants to merge 4 commits into
rapidsai:mainfrom
a-hirota:feature/csv-quoting-none-upstream

Conversation

@a-hirota

@a-hirota a-hirota commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Description

The existing documentation incorrectly stated that to_csv follows "Pandas csv.QUOTE_NONNUMERIC", but the actual default behavior is csv.QUOTE_MINIMAL. This PR corrects the documentation.

Additionally, libcudf already supports quote_style::NONE in the CSV writer (cpp/src/io/csv/writer_impl.cu), but this was not exposed in the Python API. This PR adds the quoting parameter to DataFrame.to_csv() to allow users to use csv.QUOTE_NONE, matching pandas API.

Changes

  • Fix incorrect docstring (QUOTE_NONNUMERIC → QUOTE_MINIMAL)
  • Add quoting parameter to to_csv() exposing libcudf's existing functionality
  • Add quoting method to CsvWriterOptionsBuilder in pylibcudf
  • Add tests for quoting functionality (pandas compatibility verified)

Supported quoting styles

Style Description
csv.QUOTE_MINIMAL (default) Quote only fields with special characters
csv.QUOTE_NONE Never quote fields

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Feb 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added Python Affects Python cuDF API. pylibcudf Issues specific to the pylibcudf package labels Feb 22, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Feb 22, 2026
@a-hirota a-hirota force-pushed the feature/csv-quoting-none-upstream branch 2 times, most recently from f182bd8 to 5040b31 Compare February 22, 2026 09:30
@a-hirota a-hirota marked this pull request as ready for review February 22, 2026 11:00
@a-hirota a-hirota requested a review from a team as a code owner February 22, 2026 11:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes incorrect CSV documentation and exposes the quoting parameter to allow users to control field quoting behavior in CSV output. The changes enable pandas-compatible CSV quoting with support for csv.QUOTE_MINIMAL (default) and csv.QUOTE_NONE.

Changes:

  • Corrected documentation stating the default quoting behavior is csv.QUOTE_MINIMAL (not csv.QUOTE_NONNUMERIC)
  • Added quoting parameter to DataFrame.to_csv() and cudf.io.csv.to_csv()
  • Exposed libcudf's existing quote_style::NONE support through pylibcudf's CsvWriterOptionsBuilder

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/pylibcudf/pylibcudf/libcudf/io/csv.pxd Added C++ binding declaration for quoting() method in csv_writer_options_builder
python/pylibcudf/pylibcudf/io/csv.pyx Implemented quoting() method in CsvWriterOptionsBuilder with documentation
python/pylibcudf/pylibcudf/io/csv.pyi Added type stub for quoting() method with QuoteStyle parameter
python/pylibcudf/pylibcudf/io/csv.pxd Added Cython declaration for quoting() method
python/cudf/cudf/utils/ioutils.py Updated docstring to document the quoting parameter and correct default behavior
python/cudf/cudf/tests/input_output/test_csv.py Added comprehensive tests for quoting functionality including pandas compatibility, special characters, unsupported styles, and edge cases
python/cudf/cudf/io/csv.py Added quoting parameter with validation and mapping to QuoteStyle enum
python/cudf/cudf/core/dataframe.py Added quoting parameter to DataFrame.to_csv() with default handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mroeschke mroeschke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a few comments

Comment thread python/cudf/cudf/core/dataframe.py Outdated
Comment thread python/cudf/cudf/core/dataframe.py Outdated
@a-hirota a-hirota force-pushed the feature/csv-quoting-none-upstream branch 2 times, most recently from 0b93f48 to 79c68a0 Compare February 24, 2026 07:06
@mroeschke mroeschke added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Feb 24, 2026
@mroeschke

Copy link
Copy Markdown
Contributor

/ok to test 79c68a0

…option

The existing documentation incorrectly stated that to_csv follows
"Pandas csv.QUOTE_NONNUMERIC", but the actual default behavior is
csv.QUOTE_MINIMAL. This PR corrects the documentation.

Additionally, libcudf already supports quote_style::NONE in the CSV
writer (cpp/src/io/csv/writer_impl.cu), but this was not exposed in
the Python API. This PR adds the `quoting` parameter to DataFrame.to_csv()
to allow users to use csv.QUOTE_NONE, matching pandas API.

Changes:
- Fix incorrect docstring (QUOTE_NONNUMERIC → QUOTE_MINIMAL)
- Add quoting parameter to to_csv() exposing libcudf's existing functionality
- Add quoting method to CsvWriterOptionsBuilder in pylibcudf
- Add tests for quoting functionality (pandas compatibility verified)

Supported quoting styles:
- csv.QUOTE_MINIMAL (default): Quote only fields with special characters
- csv.QUOTE_NONE: Never quote fields
@a-hirota a-hirota force-pushed the feature/csv-quoting-none-upstream branch from 79c68a0 to dc27c6a Compare February 26, 2026 01:09
@Matt711

Matt711 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

/ok to test dc27c6a

@vyasr

vyasr commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

/ok to test eda5888

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

CSV writing now accepts a quoting option from DataFrame.to_csv through cudf.io.csv into libcudf writer configuration. Tests and docs were updated to cover supported quoting modes and unsupported values.

Changes

CSV quoting support

Layer / File(s) Summary
Public entrypoint and docs
python/cudf/cudf/core/dataframe.py, python/cudf/cudf/utils/ioutils.py
DataFrame.to_csv adds quoting and forwards it to CSV writing; the CSV docstring text describes supported quoting constants and unsupported modes.
CSV writer behavior
python/cudf/cudf/io/csv.py, python/cudf/cudf/tests/input_output/test_csv.py
cudf.io.csv.to_csv defaults, validates, and propagates quoting into writer configuration, and tests cover supported values, unsupported values, special characters, and empty frames.
Pylibcudf builder surface
python/pylibcudf/pylibcudf/io/csv.pxd, python/pylibcudf/pylibcudf/io/csv.pyi, python/pylibcudf/pylibcudf/io/csv.pyx, python/pylibcudf/pylibcudf/libcudf/io/csv.pxd
The CSV writer options builder gains a quoting fluent method across the Python bindings and libcudf interface declarations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

bug, 5 - Ready to Merge

Suggested reviewers

  • mroeschke
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset and matches the implemented quoting API and documentation updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main changes: documenting quoting behavior and exposing QUOTE_NONE support in to_csv.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/cudf/cudf/tests/input_output/test_csv.py`:
- Around line 2310-2312: The pytest.raises match pattern in the CSV test uses a
regex with metacharacters but is written as a normal string, which triggers Ruff
RUF043. Update the relevant pytest.raises call in test_csv.py to use a raw
string for the match argument, keeping the existing NotImplementedError
assertion and the same regex text. Use the pytest.raises block around the
quoting-related test as the locator.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c70d63e8-f7fa-4f13-a845-6005a5e0af4f

📥 Commits

Reviewing files that changed from the base of the PR and between e5e329b and eda5888.

📒 Files selected for processing (8)
  • python/cudf/cudf/core/dataframe.py
  • python/cudf/cudf/io/csv.py
  • python/cudf/cudf/tests/input_output/test_csv.py
  • python/cudf/cudf/utils/ioutils.py
  • python/pylibcudf/pylibcudf/io/csv.pxd
  • python/pylibcudf/pylibcudf/io/csv.pyi
  • python/pylibcudf/pylibcudf/io/csv.pyx
  • python/pylibcudf/pylibcudf/libcudf/io/csv.pxd

Comment thread python/cudf/cudf/tests/input_output/test_csv.py
@vyasr

vyasr commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

/ok to test fccf1f8

@vyasr vyasr changed the title fix(csv): correct to_csv quoting documentation and expose QUOTE_NONE … fix(csv): correct to_csv quoting documentation and expose QUOTE_NONE Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants