@@ -2654,6 +2654,25 @@ def test_fwf_regression(self):
26542654 res = df .loc [:,c ]
26552655 self .assertTrue (len (res ))
26562656
2657+ def test_fwf_for_uint8 (self ):
2658+ data = """1421302965.213420 PRI=3 PGN=0xef00 DST=0x17 SRC=0x28 04 154 00 00 00 00 00 127
2659+ 1421302964.226776 PRI=6 PGN=0xf002 SRC=0x47 243 00 00 255 247 00 00 71"""
2660+ df = read_fwf (StringIO (data ),
2661+ colspecs = [(0 ,17 ),(25 ,26 ),(33 ,37 ),(49 ,51 ),(58 ,62 ),(63 ,1000 )],
2662+ names = ['time' ,'pri' ,'pgn' ,'dst' ,'src' ,'data' ],
2663+ converters = {
2664+ 'pgn' :lambda x : int (x ,16 ),
2665+ 'src' :lambda x : int (x ,16 ),
2666+ 'dst' :lambda x : int (x ,16 ),
2667+ 'data' :lambda x : len (x .split (' ' ))})
2668+
2669+ expected = DataFrame ([[1421302965.213420 ,3 ,61184 ,23 ,40 ,8 ],
2670+ [1421302964.226776 ,6 ,61442 ,None , 71 ,8 ]],
2671+ columns = ["time" , "pri" , "pgn" , "dst" , "src" ,"data" ])
2672+ expected ["dst" ] = expected ["dst" ].astype (object )
2673+
2674+ tm .assert_frame_equal (df , expected )
2675+
26572676 def test_fwf_compression (self ):
26582677 try :
26592678 import gzip
@@ -3594,7 +3613,7 @@ def test_empty_with_dup_column_pass_dtype_by_indexes(self):
35943613
35953614 data = 'one,one'
35963615 result = self .read_csv (StringIO (data ), mangle_dupe_cols = False , dtype = {0 : 'u1' , 1 : 'f' })
3597- expected = pd .concat ([Series ([], name = 'one' , dtype = 'u1' ),
3616+ expected = pd .concat ([Series ([], name = 'one' , dtype = 'u1' ),
35983617 Series ([], name = 'one' , dtype = 'f' )], axis = 1 )
35993618 tm .assert_frame_equal (result , expected )
36003619
0 commit comments