File tree 1 file changed +13
-16
lines changed
1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -602,27 +602,24 @@ class Timestamp(_Timestamp):
602
602
else :
603
603
value = self .value
604
604
605
- # GH 19206
606
- # to deal with round-off when unit is large
607
- if unit >= 1e9 :
608
- divisor = 10 ** int (np.log10(unit / 1e7 ))
609
- else :
610
- divisor = 1
611
-
612
- if unit < 1000 and unit % 1000 != 0 :
605
+ if unit < 1000 :
613
606
# for nano rounding, work with the last 6 digits separately
614
607
# due to float precision
615
608
r = (buff * (value // buff) + unit *
616
609
(rounder((value % buff) * (1 / float (unit)))).astype(' i8' ))
617
- elif unit >= 1000 and unit % 1000 != 0 :
618
- msg = ' Precision will be lost using frequency: {}'
619
- warnings.warn(msg.format(freq))
620
- r = (unit *
621
- rounder((value * divisor / float (unit)) / divisor)
622
- .astype(' i8' ))
623
610
else :
624
- r = (unit *
625
- rounder((value * divisor / float (unit)) / divisor)
611
+ if unit % 1000 != 0 :
612
+ msg = ' Precision will be lost using frequency: {}'
613
+ warnings.warn(msg.format(freq))
614
+
615
+ # GH19206
616
+ # to deal with round-off when unit is large
617
+ if unit >= 1e9 :
618
+ divisor = 10 ** int (np.log10(unit / 1e7 ))
619
+ else :
620
+ divisor = 1
621
+
622
+ r = (unit * rounder((value * divisor / float (unit)) / divisor)
626
623
.astype(' i8' ))
627
624
628
625
result = Timestamp(r, unit = ' ns' )
You can’t perform that action at this time.
0 commit comments