@@ -295,6 +295,43 @@ def test_describe_datetime_columns(self):
295295 self .assertEqual (result .columns .freq , 'MS' )
296296 self .assertEqual (result .columns .tz , expected .columns .tz )
297297
298+ def test_describe_timedelta_values (self ):
299+ # GH 6145
300+ t1 = pd .timedelta_range ('1 days' , freq = 'D' , periods = 5 )
301+ t2 = pd .timedelta_range ('1 hours' , freq = 'H' , periods = 5 )
302+ df = pd .DataFrame ({'t1' : t1 , 't2' : t2 })
303+
304+ expected = DataFrame ({'t1' : [5 , pd .Timedelta ('3 days' ),
305+ df .iloc [:, 0 ].std (),
306+ pd .Timedelta ('1 days' ),
307+ pd .Timedelta ('2 days' ),
308+ pd .Timedelta ('3 days' ),
309+ pd .Timedelta ('4 days' ),
310+ pd .Timedelta ('5 days' )],
311+ 't2' : [5 , pd .Timedelta ('3 hours' ),
312+ df .iloc [:, 1 ].std (),
313+ pd .Timedelta ('1 hours' ),
314+ pd .Timedelta ('2 hours' ),
315+ pd .Timedelta ('3 hours' ),
316+ pd .Timedelta ('4 hours' ),
317+ pd .Timedelta ('5 hours' )]},
318+ index = ['count' , 'mean' , 'std' , 'min' , '25%' ,
319+ '50%' , '75%' , 'max' ])
320+
321+ res = df .describe ()
322+ tm .assert_frame_equal (res , expected )
323+
324+ exp_repr = (" t1 t2\n "
325+ "count 5 5\n "
326+ "mean 3 days 00:00:00 0 days 03:00:00\n "
327+ "std 1 days 13:56:50.394919 0 days 01:34:52.099788\n "
328+ "min 1 days 00:00:00 0 days 01:00:00\n "
329+ "25% 2 days 00:00:00 0 days 02:00:00\n "
330+ "50% 3 days 00:00:00 0 days 03:00:00\n "
331+ "75% 4 days 00:00:00 0 days 04:00:00\n "
332+ "max 5 days 00:00:00 0 days 05:00:00" )
333+ self .assertEqual (repr (res ), exp_repr )
334+
298335 def test_reduce_mixed_frame (self ):
299336 # GH 6806
300337 df = DataFrame ({
0 commit comments