@@ -3008,16 +3008,16 @@ def test_round(self):
3008
3008
name = 'ts' )
3009
3009
assert_series_equal (result , expected )
3010
3010
self .assertEqual (result .name , self .ts .name )
3011
-
3011
+
3012
3012
def test_built_in_round (self ):
3013
3013
if not compat .PY3 :
3014
3014
raise nose .SkipTest ('build in round cannot be overriden prior to Python 3' )
3015
-
3015
+
3016
3016
s = Series ([1.123 , 2.123 , 3.123 ], index = lrange (3 ))
3017
3017
result = round (s )
3018
3018
expected_rounded0 = Series ([1. , 2. , 3. ], index = lrange (3 ))
3019
3019
self .assert_series_equal (result , expected_rounded0 )
3020
-
3020
+
3021
3021
decimals = 2
3022
3022
expected_rounded = Series ([1.12 , 2.12 , 3.12 ], index = lrange (3 ))
3023
3023
result = round (s , decimals )
@@ -5844,6 +5844,24 @@ def test_clip_against_series(self):
5844
5844
assert_series_equal (s .clip (lower , upper ), Series ([1.0 , 2.0 , 3.5 ]))
5845
5845
assert_series_equal (s .clip (1.5 , upper ), Series ([1.5 , 1.5 , 3.5 ]))
5846
5846
5847
+
5848
+ def test_clip_with_datetimes (self ):
5849
+
5850
+ # GH 11838
5851
+ # naive and tz-aware datetimes
5852
+
5853
+ t = Timestamp ('2015-12-01 09:30:30' )
5854
+ s = Series ([ Timestamp ('2015-12-01 09:30:00' ), Timestamp ('2015-12-01 09:31:00' ) ])
5855
+ result = s .clip (upper = t )
5856
+ expected = Series ([ Timestamp ('2015-12-01 09:30:00' ), Timestamp ('2015-12-01 09:30:30' ) ])
5857
+ assert_series_equal (result , expected )
5858
+
5859
+ t = Timestamp ('2015-12-01 09:30:30' , tz = 'US/Eastern' )
5860
+ s = Series ([ Timestamp ('2015-12-01 09:30:00' , tz = 'US/Eastern' ), Timestamp ('2015-12-01 09:31:00' , tz = 'US/Eastern' ) ])
5861
+ result = s .clip (upper = t )
5862
+ expected = Series ([ Timestamp ('2015-12-01 09:30:00' , tz = 'US/Eastern' ), Timestamp ('2015-12-01 09:30:30' , tz = 'US/Eastern' ) ])
5863
+ assert_series_equal (result , expected )
5864
+
5847
5865
def test_valid (self ):
5848
5866
ts = self .ts .copy ()
5849
5867
ts [::2 ] = np .NaN
0 commit comments