Skip to content

ENH: maybe_convert_objects seen NaT speed-up #27300

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 4 commits into from
Jul 9, 2019
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
15 changes: 15 additions & 0 deletions asv_bench/benchmarks/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import numpy as np

from pandas._libs import lib

import pandas as pd
from pandas.util import testing as tm

Expand All @@ -13,6 +15,19 @@
pass


class MaybeConvertObjects:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we even need this benchmark since it doesn't indicate anything from end user experience but up to @jreback

Break alone in PR lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add more tests here later as well - for more generalized cases.

def setup(self):
N = 10 ** 5

data = list(range(N))
data[0] = pd.NaT
data = np.array(data)
self.data = data

def time_maybe_convert_objects(self):
lib.maybe_convert_objects(self.data)


class Factorize:

params = [[True, False], ["int", "uint", "float", "string"]]
Expand Down
1 change: 0 additions & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ Performance improvements
- For :meth:`to_datetime` changed default value of cache parameter to ``True`` (:issue:`26043`)
- Improved performance of :class:`DatetimeIndex` and :class:`PeriodIndex` slicing given non-unique, monotonic data (:issue:`27136`).


.. _whatsnew_0250.bug_fixes:

Bug fixes
Expand Down
1 change: 1 addition & 0 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,7 @@ def maybe_convert_objects(ndarray[object] objects, bint try_float=0,
seen.timedelta_ = 1
if not (convert_datetime or convert_timedelta):
seen.object_ = 1
break
elif util.is_bool_object(val):
seen.bool_ = 1
bools[i] = val
Expand Down