File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ Improvements to existing features
107
107
Bug Fixes
108
108
~~~~~~~~~
109
109
110
+ - Bug in ``pd.tseries.frequencies.to_offset `` when argument has leading zeroes (:issue: `6391 `)
110
111
- Bug in version string gen. for dev versions with shallow clones / install from tarball (:issue: `6127 `)
111
112
- Inconsistent tz parsing Timestamp/to_datetime for current year (:issue: `5958 `)
112
113
- Indexing bugs with reordered indexes (:issue: `6252 `, :issue: `6254 `)
Original file line number Diff line number Diff line change @@ -283,11 +283,11 @@ def to_offset(freqstr):
283
283
try :
284
284
for stride , name , _ in opattern .findall (freqstr ):
285
285
offset = get_offset (name )
286
+ if stride_sign is None :
287
+ stride_sign = - 1 if stride .startswith ('-' ) else 1
286
288
if not stride :
287
289
stride = 1
288
290
stride = int (stride )
289
- if stride_sign is None :
290
- stride_sign = np .sign (stride )
291
291
offset = offset * int (np .fabs (stride ) * stride_sign )
292
292
if delta is None :
293
293
delta = offset
Original file line number Diff line number Diff line change @@ -72,6 +72,16 @@ def test_to_offset_negative():
72
72
freqstr = '-5min10s'
73
73
result = to_offset (freqstr )
74
74
assert (result .n == - 310 )
75
+
76
+
77
+ def test_to_offset_leading_zero ():
78
+ freqstr = '00H 00T 01S'
79
+ result = to_offset (freqstr )
80
+ assert (result .n == 1 )
81
+
82
+ freqstr = '-00H 03T 14S'
83
+ result = to_offset (freqstr )
84
+ assert (result .n == - 194 )
75
85
76
86
77
87
def test_anchored_shortcuts ():
You can’t perform that action at this time.
0 commit comments