Skip to content

Commit 7f678ca

Browse files
gfyoungjreback
authored andcommitted
BUG: sniffing a csv raises with only a header
Closes #7773. Validation Test. Author: gfyoung <gfyoung17@gmail.com> Closes #12914 from gfyoung/sniffer-header-only and squashes the following commits: e0cb4b0 [gfyoung] TST: Verify that #7773 is fixed
1 parent 3d2546f commit 7f678ca

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/io/tests/test_parsers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,16 @@ def test_read_with_bad_header(self):
28272827
s = StringIO(',,')
28282828
self.read_csv(s, header=[10])
28292829

2830+
def test_read_only_header_no_rows(self):
2831+
# See gh-7773
2832+
expected = DataFrame(columns=['a', 'b', 'c'])
2833+
2834+
df = self.read_csv(StringIO('a,b,c'))
2835+
tm.assert_frame_equal(df, expected)
2836+
2837+
df = self.read_csv(StringIO('a,b,c'), index_col=False)
2838+
tm.assert_frame_equal(df, expected)
2839+
28302840

28312841
class CompressionTests(object):
28322842
def test_zip(self):

0 commit comments

Comments
 (0)