Skip to content

BUG: Timedelta repr does not show nanoseconds #9309

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

Closed
sinhrks opened this issue Jan 20, 2015 · 5 comments · Fixed by #33250
Closed

BUG: Timedelta repr does not show nanoseconds #9309

sinhrks opened this issue Jan 20, 2015 · 5 comments · Fixed by #33250
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Timedelta Timedelta data type
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Jan 20, 2015

Not sure this is intended, but Timestamp and Timedelta displays nanoseconds information inconsistently.

  • Timestamp shows nanoseconds when it isn't 0
dt = pd.Timestamp(datetime.datetime.now())
h = pd.Timedelta(hours=1)

dt
#2015-01-21 00:01:05.260660
dt + offsets.Nano()
#2015-01-21 00:01:05.260660001
  • But Timedelta doesn't.
pd.Timedelta(nanoseconds=1)
#0 days 00:00:00.000000
pd.Timedelta(nanoseconds=1).nanoseconds
#1

I think Timestamp behavior is prefferable to avoid any misunderstanding.

@tvyomkesh
Copy link
Contributor

Hmm. I am seeing this in my env.

In [4]: dt = pd.Timestamp(datetime.datetime.now())

In [5]: h = pd.Timedelta(hours=1)

In [6]: dt + offsets.Nano()
Out[6]: Timestamp('2015-01-20 07:40:59.123969001')

In [7]: h + offsets.Nano()
Out[7]: numpy.timedelta64(3600000000001,'ns')

@tvyomkesh
Copy link
Contributor

Forgot to mention, I am using pd same as upstream master less than a day old.

@jreback
Copy link
Contributor

jreback commented Jan 22, 2015

the Timedela long/short printing is quite tricky - u r welcome to take a look at it
it tricky because when in an Index you need to have matching displays for all the elements otherwise it looks weird
similarly for display in a Series

@jreback
Copy link
Contributor

jreback commented Jan 22, 2015

looks like Timedelta plus An offset needs wrapping in the return type in s Timedelta

@jreback jreback added Bug Output-Formatting __repr__ of pandas objects, to_string Timedelta Timedelta data type labels Jan 22, 2015
@jreback jreback added this to the 0.16.0 milestone Jan 22, 2015
@sinhrks
Copy link
Member Author

sinhrks commented Jan 25, 2015

@jreback

Timedelta plus An offset needs wrapping in the return type in s Timedelta

I think this can be done in #9291 by doing your suggestion..

@tvyomkesh Ah, I noticed that I've attached an example partially include #9291. Changed the example in the body.

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 5, 2015
@jorisvandenbossche jorisvandenbossche changed the title BUG/API: Timestamp and Timedelta repr nanoseconds differently BUG: Timedelta repr does not show nanoseconds Jun 30, 2019
@jreback jreback modified the milestones: Contributions Welcome, 1.1 Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants