Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
BUG/PERF: offsets.apply doesnt preserve nanosecond #7697
Conversation
jreback
and 1 other
commented on an outdated diff
Jul 8, 2014
| @@ -26,15 +27,17 @@ | ||
| # convert to/from datetime/timestamp to allow invalid Timestamp ranges to pass thru | ||
| def as_timestamp(obj): | ||
| + if isinstance(obj, Timestamp): | ||
| + return obj | ||
| + if type(obj) == date: |
jreback
Contributor
|
jreback
and 1 other
commented on an outdated diff
Jul 8, 2014
| return Timestamp(obj) | ||
| except (OutOfBoundsDatetime): | ||
| pass | ||
| return obj | ||
| -def as_datetime(obj): | ||
| +def as_datetime(obj, warn=False): |
sinhrks
Member
|
jreback
added Bug Performance Frequency
labels
Jul 8, 2014
jreback
added this to the
0.15.0
milestone
Jul 8, 2014
sinhrks
referenced
this pull request
Jul 9, 2014
Merged
ENH/BUG: Offset.apply dont preserve time #7375
|
@sinhrks revisit? |
|
@jreback Rebased. Is any other thing required? |
|
Affected offset (reset nanosecond)If the aply logic includes
Affected offset (dateutil support)
|
Caused by these:
https://github.com/pydata/pandas/blob/master/pandas/tslib.pyx#784
https://github.com/pydata/pandas/blob/master/pandas/tslib.pyx#784 |
sinhrks
referenced
this pull request
Jul 22, 2014
Merged
BUG: DateOffset weekday around DST produces unexpected results. fixes #5175 #5292
|
not sure what you mean (about Tick being calced more than once). The 2nd time is simply int_64 addition. AFAICT. |
|
Yeah all operations are necessary. What I meant is every time Actually this is not affects to performance so much, thus it is possible to leave it as normal property. |
|
I think that |
|
@sinhrks otherwise this looks ok. It just changes a lot of code so trying to review. |
|
OK, modified to normal |
|
seems, |
jreback
commented on the diff
Jul 22, 2014
| + if self.normalize: | ||
| + # normalize_date returns normal datetime | ||
| + result = tslib.normalize_date(result) | ||
| + result = Timestamp(result) | ||
| + | ||
| + # nanosecond may be deleted depending on offset process | ||
| + if not self.normalize and nano != 0: | ||
| + if not isinstance(self, Nano) and result.nanosecond != nano: | ||
| + if result.tz is not None: | ||
| + # convert to UTC | ||
| + value = tslib.tz_convert_single(result.value, 'UTC', result.tz) | ||
| + else: | ||
| + value = result.value | ||
| + result = Timestamp(value + nano) | ||
| + | ||
| + if tz is not None and result.tzinfo is None: |
jreback
Contributor
|
|
|
|
ok, ping when green |
|
@jreback now green. |
jreback
added a commit
that referenced
this pull request
Jul 25, 2014
|
|
jreback |
415fbfc
|
jreback
merged commit 415fbfc
into pandas-dev:master
Jul 25, 2014
1 check passed
|
@sinhrks thanks for this...cleans up a large amount of code..... |
sinhrks commentedJul 8, 2014
Main Fix is to preserve nanosecond info which can lost during
offset.apply, but it also includes:NOTE: This caches
Tick.deltabecause it was calculated 3 times repeatedly, but does it cause any side effect?Before
After the fix