@@ -2654,6 +2654,25 @@ def test_fwf_regression(self):
2654
2654
res = df .loc [:,c ]
2655
2655
self .assertTrue (len (res ))
2656
2656
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
+
2657
2676
def test_fwf_compression (self ):
2658
2677
try :
2659
2678
import gzip
@@ -3594,7 +3613,7 @@ def test_empty_with_dup_column_pass_dtype_by_indexes(self):
3594
3613
3595
3614
data = 'one,one'
3596
3615
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' ),
3598
3617
Series ([], name = 'one' , dtype = 'f' )], axis = 1 )
3599
3618
tm .assert_frame_equal (result , expected )
3600
3619
0 commit comments