Skip to content

Conversation

@tvyomkesh
Copy link
Contributor

closes #9273

This patch adds nanoseconds keyword support in Timedelta constructor.

In [1]: from pandas import Timedelta

In [2]: td = Timedelta(nanoseconds=1)

In [3]: td1 = Timedelta(microseconds=1)

In [4]: td.components
Out[4]: Components(days=0, hours=0, minutes=0, seconds=0, milliseconds=0, microseconds=0, nanoseconds=1)

In [5]: (td + td1).components
Out[5]: Components(days=0, hours=0, minutes=0, seconds=0, milliseconds=0, microseconds=1, nanoseconds=1)

@jreback jreback added API Design Timedelta Timedelta data type labels Jan 18, 2015
@jreback jreback added this to the 0.16.0 milestone Jan 18, 2015
pandas/tslib.pyx Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a nitpick - I think the following is better

nano = kwargs.pop('nanoseconds',0)
value = convert_to_timedelta64(timedelta(**kwargs),'ns',False) + nano

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok fine. done.

@jreback
Copy link
Contributor

jreback commented Jan 19, 2015

minor comment. ping when you have pushed

@tvyomkesh
Copy link
Contributor Author

yes, much better that way. done. thanks.

jreback added a commit that referenced this pull request Jan 19, 2015
GH 9273: Timedelta constructor should accept nanoseconds keyword.
@jreback jreback merged commit b2ce495 into pandas-dev:master Jan 19, 2015
@jreback
Copy link
Contributor

jreback commented Jan 19, 2015

thanks!

@tvyomkesh tvyomkesh deleted the vyom/pd_issue_9273 branch January 19, 2015 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Design Timedelta Timedelta data type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pd.Timedelta constructor should accept nanoseconds attribute in the arguments

2 participants