Skip to content

Commit

Permalink
Allow passing index_col=False in dd.read_csv (dask#9961)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldleslie authored Oct 4, 2023
1 parent 8ba4475 commit 62dbbff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dask/dataframe/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,12 @@ def read_pandas(
lineterminator = "\n"
if include_path_column and isinstance(include_path_column, bool):
include_path_column = "path"
if "index" in kwargs or "index_col" in kwargs:
if "index" in kwargs or (
"index_col" in kwargs and kwargs.get("index_col") is not False
):
raise ValueError(
"Keywords 'index' and 'index_col' not supported. "
f"Use dd.{reader_name}(...).set_index('my-index') instead"
"Keywords 'index' and 'index_col' not supported, except for "
"'index_col=False'. Use dd.{reader_name}(...).set_index('my-index') instead"
)
for kw in ["iterator", "chunksize"]:
if kw in kwargs:
Expand Down
4 changes: 4 additions & 0 deletions dask/dataframe/io/tests/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,10 @@ def test_index_col():
except ValueError as e:
assert "set_index" in str(e)

df = pd.read_csv(fn, index_col=False)
ddf = dd.read_csv(fn, blocksize=30, index_col=False)
assert_eq(df, ddf, check_index=False)


def test_read_csv_with_datetime_index_partitions_one():
with filetext(timeseries) as fn:
Expand Down

0 comments on commit 62dbbff

Please sign in to comment.