@@ -374,7 +374,7 @@ def test_sample(self):
374
374
375
375
self ._compare (o .sample (frac = 0.7 ,random_state = np .random .RandomState (test )),
376
376
o .sample (frac = 0.7 , random_state = np .random .RandomState (test )))
377
-
377
+
378
378
379
379
# Check for error when random_state argument invalid.
380
380
with tm .assertRaises (ValueError ):
@@ -418,7 +418,7 @@ def test_sample(self):
418
418
with tm .assertRaises (ValueError ):
419
419
bad_weight_series = Series ([0 ,0 ,0.2 ])
420
420
o .sample (n = 4 , weights = bad_weight_series )
421
-
421
+
422
422
# Check won't accept negative weights
423
423
with tm .assertRaises (ValueError ):
424
424
bad_weights = [- 0.1 ]* 10
@@ -545,7 +545,7 @@ def test_sample(self):
545
545
s = Series ([1 ,0 ,0 ], index = [3 ,5 ,9 ])
546
546
assert_frame_equal (df .loc [[3 ]], df .sample (1 , weights = s ))
547
547
548
- # Weights have index values to be dropped because not in
548
+ # Weights have index values to be dropped because not in
549
549
# sampled DataFrame
550
550
s2 = Series ([0.001 ,0 ,10000 ], index = [3 ,5 ,10 ])
551
551
assert_frame_equal (df .loc [[3 ]], df .sample (1 , weights = s2 ))
@@ -1423,6 +1423,27 @@ def test_spline_smooth(self):
1423
1423
self .assertNotEqual (s .interpolate (method = 'spline' , order = 3 , s = 0 )[5 ],
1424
1424
s .interpolate (method = 'spline' , order = 3 )[5 ])
1425
1425
1426
+ def test_spline_interpolation (self ):
1427
+ tm ._skip_if_no_scipy ()
1428
+
1429
+ s = Series (np .arange (10 )** 2 )
1430
+ s [np .random .randint (0 ,9 ,3 )] = np .nan
1431
+ result1 = s .interpolate (method = 'spline' , order = 1 )
1432
+ expected1 = s .interpolate (method = 'spline' , order = 1 )
1433
+ assert_series_equal (result1 , expected1 )
1434
+
1435
+ # GH #10633
1436
+ def test_spline_error (self ):
1437
+ tm ._skip_if_no_scipy ()
1438
+
1439
+ s = pd .Series (np .arange (10 )** 2 )
1440
+ s [np .random .randint (0 ,9 ,3 )] = np .nan
1441
+ with tm .assertRaises (ValueError ):
1442
+ s .interpolate (method = 'spline' )
1443
+
1444
+ with tm .assertRaises (ValueError ):
1445
+ s .interpolate (method = 'spline' , order = 0 )
1446
+
1426
1447
def test_metadata_propagation_indiv (self ):
1427
1448
1428
1449
# groupby
0 commit comments