@@ -1514,11 +1514,35 @@ def test_mixed_string_strl(self):
1514
1514
{'mixed' : None ,
1515
1515
'number' : 1 }
1516
1516
]
1517
-
1518
1517
output = pd .DataFrame (output )
1518
+ output .number = output .number .astype ('int32' )
1519
+
1519
1520
with tm .ensure_clean () as path :
1520
1521
output .to_stata (path , write_index = False , version = 117 )
1521
1522
reread = read_stata (path )
1522
1523
expected = output .fillna ('' )
1523
- expected .number = expected .number .astype ('int32' )
1524
1524
tm .assert_frame_equal (reread , expected )
1525
+
1526
+ # Check strl supports all None (null)
1527
+ output .loc [:, 'mixed' ] = None
1528
+ output .to_stata (path , write_index = False , convert_strl = ['mixed' ],
1529
+ version = 117 )
1530
+ reread = read_stata (path )
1531
+ expected = output .fillna ('' )
1532
+ tm .assert_frame_equal (reread , expected )
1533
+
1534
+ @pytest .mark .parametrize ('version' , [114 , 117 ])
1535
+ def test_all_none_exception (self , version ):
1536
+ output = [
1537
+ {'none' : 'none' ,
1538
+ 'number' : 0 },
1539
+ {'none' : None ,
1540
+ 'number' : 1 }
1541
+ ]
1542
+ output = pd .DataFrame (output )
1543
+ output .loc [:, 'none' ] = None
1544
+ with tm .ensure_clean () as path :
1545
+ with pytest .raises (ValueError ) as excinfo :
1546
+ output .to_stata (path , version = version )
1547
+ assert 'Only string-like' in excinfo .value .args [0 ]
1548
+ assert 'Column `none`' in excinfo .value .args [0 ]
0 commit comments