@@ -906,37 +906,43 @@ def test_index_with_nan(self):
906
906
y = df .set_index (['id1' , 'id2' , 'id3' ])
907
907
result = y .to_string ()
908
908
expected = u (' value\n id1 id2 id3 \n 1a3 NaN 78d 123\n 9h4 d67 79d 64' )
909
- self .assert_ (result == expected )
909
+ self .assertEqual (result , expected )
910
910
911
911
# index
912
912
y = df .set_index ('id2' )
913
913
result = y .to_string ()
914
914
expected = u (' id1 id3 value\n id2 \n NaN 1a3 78d 123\n d67 9h4 79d 64' )
915
- self .assert_ (result == expected )
915
+ self .assertEqual (result , expected )
916
+
917
+ # with append (this failed in 0.12)
918
+ y = df .set_index (['id1' , 'id2' ]).set_index ('id3' , append = True )
919
+ result = y .to_string ()
920
+ expected = u (' value\n id1 id2 id3 \n 1a3 NaN 78d 123\n 9h4 d67 79d 64' )
921
+ self .assertEqual (result , expected )
916
922
917
923
# all-nan in mi
918
924
df2 = df .copy ()
919
925
df2 .ix [:,'id2' ] = np .nan
920
926
y = df2 .set_index ('id2' )
921
927
result = y .to_string ()
922
928
expected = u (' id1 id3 value\n id2 \n NaN 1a3 78d 123\n NaN 9h4 79d 64' )
923
- self .assert_ (result == expected )
929
+ self .assertEqual (result , expected )
924
930
925
931
# partial nan in mi
926
932
df2 = df .copy ()
927
933
df2 .ix [:,'id2' ] = np .nan
928
934
y = df2 .set_index (['id2' ,'id3' ])
929
935
result = y .to_string ()
930
936
expected = u (' id1 value\n id2 id3 \n NaN 78d 1a3 123\n 79d 9h4 64' )
931
- self .assert_ (result == expected )
937
+ self .assertEqual (result , expected )
932
938
933
939
df = DataFrame ({'id1' : {0 : np .nan , 1 : '9h4' }, 'id2' : {0 : np .nan , 1 : 'd67' },
934
940
'id3' : {0 : np .nan , 1 : '79d' }, 'value' : {0 : 123 , 1 : 64 }})
935
941
936
942
y = df .set_index (['id1' ,'id2' ,'id3' ])
937
943
result = y .to_string ()
938
944
expected = u (' value\n id1 id2 id3 \n NaN NaN NaN 123\n 9h4 d67 79d 64' )
939
- self .assert_ (result == expected )
945
+ self .assertEqual (result , expected )
940
946
941
947
def test_to_string (self ):
942
948
from pandas import read_table
0 commit comments