Skip to content

Commit 613aff5

Browse files
committed
BUG: Fixed typo related bug to resolve #9266
Fixed typo in parsers.py BUG: Fixed typo-related bug to resolve #9266 Fixed column selection in test cases
1 parent 43f31cf commit 613aff5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

doc/source/whatsnew/v0.17.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,5 @@ Bug Fixes
143143
- Bug in `Series.from_csv` with ``header`` kwarg not setting the ``Series.name`` or the ``Series.index.name`` (:issue:`10483`)
144144

145145
- Bug in `groupby.var` which caused variance to be inaccurate for small float values (:issue:`10448`)
146+
147+
- Bug in `_convert_to_ndarrays` which cause an `AttributeError` in some cases (:issue:`9266`)

pandas/io/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def _convert_to_ndarrays(self, dct, na_values, na_fvalues, verbose=False,
997997
try:
998998
values = lib.map_infer(values, conv_f)
999999
except ValueError:
1000-
mask = lib.ismember(values, na_values).view(np.uin8)
1000+
mask = lib.ismember(values, na_values).view(np.uint8)
10011001
values = lib.map_infer_mask(values, conv_f, mask)
10021002
coerce_type = False
10031003

pandas/io/tests/test_parsers.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,27 @@ def test_fwf_compression(self):
26792679
compression=comp_name)
26802680
tm.assert_frame_equal(result, expected)
26812681

2682+
def test_fwf_for_uint8(self):
2683+
data = """1421302965.213420 PRI=3 PGN=0xef00 DST=0x17 SRC=0x28 04 154 00 00 00 00 00 127
2684+
1421302964.226776 PRI=6 PGN=0xf002 SRC=0x47 243 00 00 255 247 00 00 71"""
2685+
df = read_fwf(StringIO(data),
2686+
colspecs=[(0,17),(25,26),(33,37),(49,51),(58,62),(63,1000)],
2687+
names=['time','pri','pgn','dst','src','data'],
2688+
converters={
2689+
'pgn':lambda x: int(x,16),
2690+
'src':lambda x: int(x,16),
2691+
'dst':lambda x: int(x,16),
2692+
'data':lambda x: len(x.split(' '))})
2693+
2694+
expected = DataFrame([[1421302965.213420,3,61184,23,40,8],
2695+
[1421302964.226776,6,61442,None, 71,8]],
2696+
columns = ["time", "pri", "pgn", "dst", "src","data"])
2697+
2698+
# Hacky fix for dst column dtype
2699+
expected["dst"] = expected["dst"].astype(object)
2700+
2701+
tm.assert_frame_equal(df, expected)
2702+
26822703
def test_BytesIO_input(self):
26832704
if not compat.PY3:
26842705
raise nose.SkipTest("Bytes-related test - only needs to work on Python 3")

0 commit comments

Comments
 (0)