Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,8 @@ cdef inline bint c_is_list_like(object obj, bint allow_sets) except -1:
and not (util.is_array(obj) and obj.ndim == 0)
# exclude sets if allow_sets is False
and not (allow_sets is False and isinstance(obj, abc.Set))
# allow dict_keys objects
or isinstance(obj, abc.KeysView)
)


Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/io/parser/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,3 +2221,12 @@ def test_read_table_delim_whitespace_non_default_sep(all_parsers):
)
with pytest.raises(ValueError, match=msg):
parser.read_table(f, delim_whitespace=True, sep=",")


def test_dict_keys_as_names(all_parsers):
data = "a,b\n1,2"

keys = {"a": int, "b": int}.keys()
parser = all_parsers

parser.read_csv(StringIO(data), names=keys)