Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Datetime-like indexes summary should output the same format #9116

Merged
merged 1 commit into from
Jan 5, 2015

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Dec 20, 2014

Related to #6469. Made all datetime-like indexes summary should output the same format.

Before

didx = pd.date_range('2014-12-20', freq='M', periods=3)
pidx = pd.period_range('2014-12-20', freq='M', periods=3)
tdidx = pd.timedelta_range(start='1 days', freq='D', periods=3)

didx.summary()
# DatetimeIndex: 3 entries, 2014-12-31 00:00:00 to 2015-02-28 00:00:00
# Freq: M

pidx.summary()
# PeriodIndex: 3 entries, 2014-12 to 2015-02

tdidx.summary()
# TimedeltaIndex: 3 entries, '1 days' to '3 days'
# Freq: <Day>

After

  • DatetimeIndex and PeriodIndex use _format_func. This made DatetimeIndex not to output hour/minutes.. when its frequency is more than a day.
  • PeriodIndex outputs its freq
  • TimedeltaIndex has no changes.
# DatetimeIndex: 3 entries, 2014-12-31 to 2015-02-28
# Freq: M

# PeriodIndex: 3 entries, 2014-12 to 2015-02
# Freq: M

# TimedeltaIndex: 3 entries, '1 days' to '3 days'
# Freq: <Day>

@jreback
Copy link
Contributor

jreback commented Dec 20, 2014

somewhat separately the freq printing for TimeDeltaIndex is showing the actual obj and not the string repr

@jreback jreback added Output-Formatting __repr__ of pandas objects, to_string Datetime Datetime data dtype labels Dec 20, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 20, 2014
@sinhrks
Copy link
Member Author

sinhrks commented Dec 20, 2014

Yeah, TimedeltaIndex.freqstr is not compat with others. Can I fix this in the same PR, or shoudld be separate?

# DatetimeIndex
didx.freqstr
# M

# TimedeltaIndex
tdidx.freqstr
# <Day>

@jreback
Copy link
Contributor

jreback commented Dec 20, 2014

I think u can fix it here
it shouldn't break anything (if it gets too complicated do a separate one)

@@ -459,3 +459,20 @@ def repeat(self, repeats, axis=None):
"""
return self._simple_new(self.values.repeat(repeats),
name=self.name)

def summary(self, name=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you now you are modifying it also add a docstring?

@sinhrks
Copy link
Member Author

sinhrks commented Jan 3, 2015

@jreback, @jorisvandenbossche
Updated, could you check?

@jorisvandenbossche
Copy link
Member

Looks good to me!

jreback added a commit that referenced this pull request Jan 5, 2015
API: Datetime-like indexes `summary` should output the same format
@jreback jreback merged commit f481283 into pandas-dev:master Jan 5, 2015
@jreback
Copy link
Contributor

jreback commented Jan 5, 2015

thanks @sinhrks

@sinhrks sinhrks deleted the dt_summary branch January 17, 2015 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants