File tree Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -537,7 +537,6 @@ Enhancements
537537 is frequency conversion. See :ref: `the docs<timedeltas.timedeltas_convert> ` for the docs.
538538
539539 .. ipython :: python
540- :okexcept:
541540
542541 import datetime
543542 td = pd.Series(pd.date_range(' 20130101' , periods = 4 )) - pd.Series(
@@ -546,13 +545,41 @@ Enhancements
546545 td[3 ] = np.nan
547546 td
548547
548+ .. code-block :: ipython
549+
549550 # to days
550- td / np.timedelta64(1 , ' D' )
551- td.astype(' timedelta64[D]' )
551+ In [63]: td / np.timedelta64(1, 'D')
552+ Out[63]:
553+ 0 31.000000
554+ 1 31.000000
555+ 2 31.003507
556+ 3 NaN
557+ dtype: float64
558+
559+ In [64]: td.astype('timedelta64[D]')
560+ Out[64]:
561+ 0 31.0
562+ 1 31.0
563+ 2 31.0
564+ 3 NaN
565+ dtype: float64
552566
553567 # to seconds
554- td / np.timedelta64(1 , ' s' )
555- td.astype(' timedelta64[s]' )
568+ In [65]: td / np.timedelta64(1, 's')
569+ Out[65]:
570+ 0 2678400.0
571+ 1 2678400.0
572+ 2 2678703.0
573+ 3 NaN
574+ dtype: float64
575+
576+ In [66]: td.astype('timedelta64[s]')
577+ Out[66]:
578+ 0 2678400.0
579+ 1 2678400.0
580+ 2 2678703.0
581+ 3 NaN
582+ dtype: float64
556583
557584 Dividing or multiplying a ``timedelta64[ns] `` Series by an integer or integer Series
558585
You can’t perform that action at this time.
0 commit comments