Skip to content

Commit 07405b4

Browse files
committed
Merge pull request #5802 from jreback/td_perf
PERF: fix infer_dtype to properly infer a Series (GH5801)
2 parents 2a9245e + dfa808d commit 07405b4

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Experimental Features
6464
Improvements to existing features
6565
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6666

67+
- perf improvements in Series datetime/timedelta binary operations (:issue:`5801`)
68+
6769
Bug Fixes
6870
~~~~~~~~~
6971

pandas/src/inference.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def infer_dtype(object _values):
3535

3636
if isinstance(_values, np.ndarray):
3737
values = _values
38+
elif hasattr(_values,'values'):
39+
values = _values.values
3840
else:
3941
if not isinstance(_values, list):
4042
_values = list(_values)

vb_suite/binary_ops.py

+13
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
Benchmark("df[(df>0) & (df2>0)]", setup, name='frame_multi_and_no_ne',cleanup="expr.set_use_numexpr(True)",
104104
start_date=datetime(2013, 2, 26))
105105

106+
#----------------------------------------------------------------------
107+
# timeseries
108+
106109
setup = common_setup + """
107110
N = 1000000
108111
halfway = N // 2 - 1
@@ -114,3 +117,13 @@
114117
start_date=datetime(2013, 9, 27))
115118
series_timestamp_compare = Benchmark("s <= ts", setup,
116119
start_date=datetime(2012, 2, 21))
120+
121+
setup = common_setup + """
122+
N = 1000000
123+
s = Series(date_range('20010101', periods=N, freq='s'))
124+
"""
125+
126+
timestamp_ops_diff1 = Benchmark("s.diff()", setup,
127+
start_date=datetime(2013, 1, 1))
128+
timestamp_ops_diff2 = Benchmark("s-s.shift()", setup,
129+
start_date=datetime(2013, 1, 1))

0 commit comments

Comments
 (0)