-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: GH29461 strftime() with nanoseconds for Timestamp #34317
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls also add a note in 1.1. bug fix for datetime section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you see if we have any benchmarks for these and run them (or add some and run them).
I am afraid this is going to be quite slow.
pls also merge master |
Added benchmarks. Looks like it does have a bit of a performance impact.
Weirdly, the performance hit was greater when we DON'T have %f and we call super() (at least in terms of percentage). We shouldn't really be seeing any change in that case. I can't quite figure that one out. I see a few options
But I think if we can figure out why immediately calling super() is so much slower we'll have a better idea of where we need to make improvements. |
@matteosantama I am more interested in |
Ah, of course. I wrote a benchmark, and it seems that performance has actually increased. I actually don't find this too surprising because
|
asv_bench/benchmarks/timeseries.py
Outdated
|
||
def time_dt_accessor(self, tz): | ||
def time_dt_accessor(self, *args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use explicit parameters here instead of args?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll fix that.
pandas/_libs/tslibs/timestamps.pyx
Outdated
# only do additional processing if necessary | ||
if self.nanosecond and '%f' in format: | ||
newformat = [] | ||
for ch in format: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you not just use a regex here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, OK that would probably be cleaner
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
The new method displays %f to the full precision, including trailing zeroes. I could add a check that only displays nanoseconds if they are non-zero.