@@ -851,6 +851,21 @@ def test_print_unicode_columns(self):
851
851
df = pd .DataFrame ({u"\u05d0 " :[1 ,2 ,3 ],"\u05d1 " :[4 ,5 ,6 ],"c" :[7 ,8 ,9 ]})
852
852
print (df .columns ) # should not raise UnicodeDecodeError
853
853
854
+ def test_unicode_string_with_unicode (self ):
855
+ idx = Index (range (1000 ))
856
+
857
+ if py3compat .PY3 :
858
+ str (idx )
859
+ else :
860
+ unicode (idx )
861
+
862
+ def test_bytestring_with_unicode (self ):
863
+ idx = Index (range (1000 ))
864
+ if py3compat .PY3 :
865
+ bytes (idx )
866
+ else :
867
+ str (idx )
868
+
854
869
class TestMultiIndex (unittest .TestCase ):
855
870
856
871
def setUp (self ):
@@ -1680,6 +1695,24 @@ def test_repr_with_unicode_data(self):
1680
1695
index = pd .DataFrame (d ).set_index (["a" ,"b" ]).index
1681
1696
self .assertFalse ("\\ u" in repr (index )) # we don't want unicode-escaped
1682
1697
1698
+ def test_unicode_string_with_unicode (self ):
1699
+ d = {"a" :[u"\u05d0 " ,2 ,3 ],"b" :[4 ,5 ,6 ],"c" :[7 ,8 ,9 ]}
1700
+ idx = pd .DataFrame (d ).set_index (["a" ,"b" ]).index
1701
+
1702
+ if py3compat .PY3 :
1703
+ str (idx )
1704
+ else :
1705
+ unicode (idx )
1706
+
1707
+ def test_bytestring_with_unicode (self ):
1708
+ d = {"a" :[u"\u05d0 " ,2 ,3 ],"b" :[4 ,5 ,6 ],"c" :[7 ,8 ,9 ]}
1709
+ idx = pd .DataFrame (d ).set_index (["a" ,"b" ]).index
1710
+
1711
+ if py3compat .PY3 :
1712
+ bytes (idx )
1713
+ else :
1714
+ str (idx )
1715
+
1683
1716
def test_get_combined_index ():
1684
1717
from pandas .core .index import _get_combined_index
1685
1718
result = _get_combined_index ([])
0 commit comments