Skip to content

Commit

Permalink
API: use ISO8601 format for Period repr, close #1776
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Sep 9, 2012
1 parent a0b59f8 commit 7a83180
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pandas 0.9.0
- The internal HDF5 data arrangement for DataFrames has been
transposed. Legacy files will still be readable by HDFStore (#1834, #1824)
- Legacy cruft removed: pandas.stats.misc.quantileTS
- Use ISO8601 format for Period repr: monthly, daily, and on down (#1776)

**Bug fixes**

Expand Down
10 changes: 5 additions & 5 deletions pandas/src/plib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,21 @@ def period_format(int64_t value, int freq, object fmt=None):
elif freq_group == 2000: # FR_QTR
fmt = b'%FQ%q'
elif freq_group == 3000: # FR_MTH
fmt = b'%b-%Y'
fmt = b'%Y-%m'
elif freq_group == 4000: # WK
left = period_asfreq(value, freq, 6000, 0)
right = period_asfreq(value, freq, 6000, 1)
return '%s/%s' % (period_format(left, 6000),
period_format(right, 6000))
elif (freq_group == 5000 # BUS
or freq_group == 6000): # DAY
fmt = b'%d-%b-%Y'
fmt = b'%Y-%m-%d'
elif freq_group == 7000: # HR
fmt = b'%d-%b-%Y %H:00'
fmt = b'%Y-%m-%d %H:00'
elif freq_group == 8000: # MIN
fmt = b'%d-%b-%Y %H:%M'
fmt = b'%Y-%m-%d %H:%M'
elif freq_group == 9000: # SEC
fmt = b'%d-%b-%Y %H:%M:%S'
fmt = b'%Y-%m-%d %H:%M:%S'
else:
raise ValueError('Unknown freq: %d' % freq)

Expand Down
5 changes: 4 additions & 1 deletion pandas/tseries/tests/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ def test_freq_str(self):

def test_repr(self):
p = Period('Jan-2000')
self.assert_('Jan-2000' in repr(p))
self.assert_('2000-01' in repr(p))

p = Period('2000-12-15')
self.assert_('2000-12-15' in repr(p))

def test_strftime(self):
p = Period('2000-1-1 12:34:12', freq='S')
Expand Down

0 comments on commit 7a83180

Please sign in to comment.