Skip to content

ENH: Support timespec argument in Timestamp.isoformat() #44397

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

Merged
merged 5 commits into from
Nov 14, 2021

Conversation

swt2c
Copy link
Contributor

@swt2c swt2c commented Nov 11, 2021

This is an update of PR #38550. I added support for "nanoseconds" as an argument, expanded the test cases, and addressed most of the comments in the original PR.

@jreback jreback added Enhancement Datetime Datetime data dtype labels Nov 12, 2021
@jreback jreback added this to the 1.4 milestone Nov 12, 2021
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

looks good a couple of questions.

-------
str

Examples
Copy link
Contributor

Choose a reason for hiding this comment

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

this example should be for NaT (to be honest dont' need it here though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem I ran into - there was a test failure because the docstrings differed between NaT and Timestamp, so that's why I copied the docstring into NaT. Do you have any advice about that?

Copy link
Contributor

Choose a reason for hiding this comment

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

right we have tests that confirm this, but since we are not explicitly making these differnt you can change the test

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, so I ended up reverting the docstring change to NaT and updated the test to ignore the docstring changes with Timestamp.

(ts_no_ns, "seconds", "2019-05-18T15:17:08"),
(ts_no_ns, "nanoseconds", "2019-05-18T15:17:08.132263000"),
(ts_ns, "auto", "2019-05-18T15:17:08.132263123"),
(ts_ns, "hours", "2019-05-18T15"),
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also run on NaT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure it made sense to run the same tests on NaT(?) but I did add a test to the NaT tests to check that it at least accepts the timespec parameter.

@jreback
Copy link
Contributor

jreback commented Nov 14, 2021

thanks @swt2c lgtm.

cc @mroeschke if any comments

@mroeschke mroeschke merged commit f744931 into pandas-dev:master Nov 14, 2021
@mroeschke
Copy link
Member

Great, thanks @swt2c

nickleus27 pushed a commit to nickleus27/pandas that referenced this pull request Nov 28, 2021
…4397)

* ENH: Support timespec argument in Timestamp.isoformat()

* Get rid of tabs

* Copy isoformat docstring to NaTType

* Remove NaT docstring changes & update NaT tests

* Fix another black issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.Timestamp.isoformat does not implement keyword timespec
3 participants