Skip to content

Commit 93e23a7

Browse files
jbrockmendeljreback
authored andcommitted
Remove property that re-computed microsecond (#17331)
1 parent fd137f5 commit 93e23a7

File tree

4 files changed

+62
-5
lines changed

4 files changed

+62
-5
lines changed

asv_bench/benchmarks/timestamp.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from .pandas_vb_common import *
2+
from pandas import to_timedelta, Timestamp
3+
4+
5+
class TimestampProperties(object):
6+
goal_time = 0.2
7+
8+
def setup(self):
9+
self.ts = Timestamp('2017-08-25 08:16:14')
10+
11+
def time_tz(self):
12+
self.ts.tz
13+
14+
def time_offset(self):
15+
self.ts.offset
16+
17+
def time_dayofweek(self):
18+
self.ts.dayofweek
19+
20+
def time_weekday_name(self):
21+
self.ts.weekday_name
22+
23+
def time_dayofyear(self):
24+
self.ts.dayofyear
25+
26+
def time_week(self):
27+
self.ts.week
28+
29+
def time_quarter(self):
30+
self.ts.quarter
31+
32+
def time_days_in_month(self):
33+
self.ts.days_in_month
34+
35+
def time_freqstr(self):
36+
self.ts.freqstr
37+
38+
def time_is_month_start(self):
39+
self.ts.is_month_start
40+
41+
def time_is_month_end(self):
42+
self.ts.is_month_end
43+
44+
def time_is_quarter_start(self):
45+
self.ts.is_quarter_start
46+
47+
def time_is_quarter_end(self):
48+
self.ts.is_quarter_end
49+
50+
def time_is_year_start(self):
51+
self.ts.is_quarter_end
52+
53+
def time_is_year_end(self):
54+
self.ts.is_quarter_end
55+
56+
def time_is_leap_year(self):
57+
self.ts.is_quarter_end
58+
59+
def time_microsecond(self):
60+
self.ts.microsecond

doc/source/whatsnew/v0.21.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ Performance Improvements
382382

383383
- Improved performance of instantiating :class:`SparseDataFrame` (:issue:`16773`)
384384
- :attr:`Series.dt` no longer performs frequency inference, yielding a large speedup when accessing the attribute (:issue:`17210`)
385-
385+
- :attr:`Timestamp.microsecond` no longer re-computes on attribute access (:issue:`17331`)
386386

387387
.. _whatsnew_0210.bug_fixes:
388388

pandas/_libs/period.pyx

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
from datetime import datetime, date, timedelta
23
import operator
34

pandas/_libs/tslib.pyx

-4
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,6 @@ class Timestamp(_Timestamp):
544544

545545
weekofyear = week
546546

547-
@property
548-
def microsecond(self):
549-
return self._get_field('us')
550-
551547
@property
552548
def quarter(self):
553549
return self._get_field('q')

0 commit comments

Comments
 (0)