Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify column names in dd.read_csv #1740

Merged
merged 1 commit into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions dask/dataframe/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def pandas_read_text(reader, b, header, kwargs, dtypes=None, columns=None,

if enforce and columns and (list(df.columns) != list(columns)):
raise ValueError("Columns do not match", df.columns, columns)
elif columns:
df.columns = columns
return df


Expand Down
11 changes: 11 additions & 0 deletions dask/dataframe/io/tests/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,17 @@ def test_read_csv_singleton_dtype():
dd.read_csv(fn, dtype=float))


def test_robust_column_mismatch():
files = csv_files.copy()
k = sorted(files)[-1]
files[k] = files[k].replace(b'name', b'Name')
with filetexts(files, mode='b'):
ddf = dd.read_csv('2014-01-*.csv')
df = pd.read_csv('2014-01-01.csv')
assert (df.columns == ddf.columns).all()
assert_eq(ddf, ddf)


############
# to_csv #
############
Expand Down