Skip to content

BUG: Fixed typo-related bug to resolve #9266 #10642

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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 doc/source/whatsnew/v0.17.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,5 @@ Bug Fixes
- Reading "famafrench" data via ``DataReader`` results in HTTP 404 error because of the website url is changed (:issue:`10591`).

- Bug in `read_msgpack` where DataFrame to decode has duplicate column names (:issue:`9618`)

- Bug in `_convert_to_ndarrays` which caused an `AttributeError` to be raised at times (:issue:`9266`)
2 changes: 1 addition & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ def _convert_to_ndarrays(self, dct, na_values, na_fvalues, verbose=False,
try:
values = lib.map_infer(values, conv_f)
except ValueError:
mask = lib.ismember(values, na_values).view(np.uin8)
mask = lib.ismember(values, na_values).view(np.uint8)
values = lib.map_infer_mask(values, conv_f, mask)
coerce_type = False

Expand Down
21 changes: 21 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,27 @@ def test_fwf_regression(self):
res = df.loc[:,c]
self.assertTrue(len(res))

def test_fwf_for_uint8(self):
data = """1421302965.213420 PRI=3 PGN=0xef00 DST=0x17 SRC=0x28 04 154 00 00 00 00 00 127
1421302964.226776 PRI=6 PGN=0xf002 SRC=0x47 243 00 00 255 247 00 00 71"""
df = read_fwf(StringIO(data),
colspecs=[(0,17),(25,26),(33,37),(49,51),(58,62),(63,1000)],
names=['time','pri','pgn','dst','src','data'],
converters={
'pgn':lambda x: int(x,16),
'src':lambda x: int(x,16),
'dst':lambda x: int(x,16),
'data':lambda x: len(x.split(' '))})

expected = DataFrame([[1421302965.213420,3,61184,23,40,8],
[1421302964.226776,6,61442,None, 71,8]],
columns = ["time", "pri", "pgn", "dst", "src","data"])

# Hacky fix for dst column dtype
expected["dst"] = expected["dst"].astype(object)

tm.assert_frame_equal(df, expected)

def test_fwf_compression(self):
try:
import gzip
Expand Down