Skip to content

Commit 4e507af

Browse files
committed
add test for read_csv nrow=0 and low_memory=True, issue 21141
1 parent b0bee63 commit 4e507af

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/tests/io/parser/common.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import pandas as pd
1818
import pandas.util.testing as tm
19-
from pandas import DataFrame, Series, Index, MultiIndex
19+
from pandas import DataFrame, Series, Index, MultiIndex, Int64Index
2020
from pandas import compat
2121
from pandas.compat import (StringIO, BytesIO, PY3,
2222
range, lrange, u)
@@ -238,6 +238,16 @@ def test_csv_mixed_type(self):
238238
out = self.read_csv(StringIO(data))
239239
tm.assert_frame_equal(out, expected)
240240

241+
def test_csv_index_col_and_nrows(self):
242+
data = """A,B,C
243+
1,1,1,2
244+
2,2,3,4
245+
3,3,4,5
246+
"""
247+
out = self.read_csv(StringIO(data), low_memory=True, index_col=0, nrows=0)
248+
tm.assert_index_equal(out.columns, pd.Index(['A', 'B', 'C']))
249+
assert out.empty
250+
241251
def test_read_csv_dataframe(self):
242252
df = self.read_csv(self.csv1, index_col=0, parse_dates=True)
243253
df2 = self.read_table(self.csv1, sep=',', index_col=0,

0 commit comments

Comments
 (0)