23
23
from numpy .random import randn
24
24
from pandas .compat import range , lrange , lmap , zip
25
25
26
- from pandas import Series , TimeSeries , DataFrame
26
+ from pandas import Series , TimeSeries , DataFrame , _np_version_under1p9
27
27
from pandas .util .testing import (assert_series_equal , assert_almost_equal ,
28
28
assertRaisesRegexp )
29
29
import pandas .util .testing as tm
@@ -1862,8 +1862,17 @@ def test_getitem_day(self):
1862
1862
values = ['2014' , '2013/02' , '2013/01/02' ,
1863
1863
'2013/02/01 9H' , '2013/02/01 09:00' ]
1864
1864
for v in values :
1865
- with tm .assertRaises (ValueError ):
1866
- idx [v ]
1865
+
1866
+ if _np_version_under1p9 :
1867
+ with tm .assertRaises (ValueError ):
1868
+ idx [v ]
1869
+ else :
1870
+ # GH7116
1871
+ # these show deprecations as we are trying
1872
+ # to slice with non-integer indexers
1873
+ #with tm.assertRaises(IndexError):
1874
+ # idx[v]
1875
+ continue
1867
1876
1868
1877
s = Series (np .random .rand (len (idx )), index = idx )
1869
1878
assert_series_equal (s ['2013/01' ], s [0 :31 ])
@@ -1910,8 +1919,16 @@ def test_getitem_seconds(self):
1910
1919
values = ['2014' , '2013/02' , '2013/01/02' ,
1911
1920
'2013/02/01 9H' , '2013/02/01 09:00' ]
1912
1921
for v in values :
1913
- with tm .assertRaises (ValueError ):
1914
- idx [v ]
1922
+ if _np_version_under1p9 :
1923
+ with tm .assertRaises (ValueError ):
1924
+ idx [v ]
1925
+ else :
1926
+ # GH7116
1927
+ # these show deprecations as we are trying
1928
+ # to slice with non-integer indexers
1929
+ #with tm.assertRaises(IndexError):
1930
+ # idx[v]
1931
+ continue
1915
1932
1916
1933
s = Series (np .random .rand (len (idx )), index = idx )
1917
1934
@@ -2291,7 +2308,7 @@ def test_factorize(self):
2291
2308
2292
2309
exp_arr = np .array ([0 , 0 , 1 , 1 , 2 , 2 ])
2293
2310
exp_idx = PeriodIndex (['2014-01' , '2014-02' , '2014-03' ], freq = 'M' )
2294
-
2311
+
2295
2312
arr , idx = idx1 .factorize ()
2296
2313
self .assert_numpy_array_equal (arr , exp_arr )
2297
2314
self .assert_ (idx .equals (exp_idx ))
@@ -2303,7 +2320,7 @@ def test_factorize(self):
2303
2320
idx2 = pd .PeriodIndex (['2014-03' , '2014-03' , '2014-02' , '2014-01' ,
2304
2321
'2014-03' , '2014-01' ], freq = 'M' )
2305
2322
2306
- exp_arr = np .array ([2 , 2 , 1 , 0 , 2 , 0 ])
2323
+ exp_arr = np .array ([2 , 2 , 1 , 0 , 2 , 0 ])
2307
2324
arr , idx = idx2 .factorize (sort = True )
2308
2325
self .assert_numpy_array_equal (arr , exp_arr )
2309
2326
self .assert_ (idx .equals (exp_idx ))
0 commit comments