Skip to content

PERF: fix infer_dtype to properly infer a Series (GH5801) #5802

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 1 commit into from
Dec 30, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Experimental Features
Improvements to existing features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- perf improvements in Series datetime/timedelta binary operations (:issue:`5801`)

Bug Fixes
~~~~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions pandas/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def infer_dtype(object _values):

if isinstance(_values, np.ndarray):
values = _values
elif hasattr(_values,'values'):
values = _values.values
else:
if not isinstance(_values, list):
_values = list(_values)
Expand Down
13 changes: 13 additions & 0 deletions vb_suite/binary_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
Benchmark("df[(df>0) & (df2>0)]", setup, name='frame_multi_and_no_ne',cleanup="expr.set_use_numexpr(True)",
start_date=datetime(2013, 2, 26))

#----------------------------------------------------------------------
# timeseries

setup = common_setup + """
N = 1000000
halfway = N // 2 - 1
Expand All @@ -114,3 +117,13 @@
start_date=datetime(2013, 9, 27))
series_timestamp_compare = Benchmark("s <= ts", setup,
start_date=datetime(2012, 2, 21))

setup = common_setup + """
N = 1000000
s = Series(date_range('20010101', periods=N, freq='s'))
"""

timestamp_ops_diff1 = Benchmark("s.diff()", setup,
start_date=datetime(2013, 1, 1))
timestamp_ops_diff2 = Benchmark("s-s.shift()", setup,
start_date=datetime(2013, 1, 1))