Skip to content

Commit 0564aac

Browse files
committed
PERF: perf improvments in indexing with object dtypes (GH5968)
1 parent cc2c70b commit 0564aac

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Improvements to existing features
8383
- pd.show_versions() is now available for convenience when reporting issues.
8484
- perf improvements to Series.str.extract (:issue:`5944`)
8585
- perf improvments in ``dtypes/ftypes`` methods (:issue:`5968`)
86+
- perf improvments in indexing with object dtypes (:issue:`5968`)
8687

8788
.. _release.bug_fixes-0.13.1:
8889

pandas/core/internals.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,10 @@ def make_block(values, items, ref_items, klass=None, ndim=None, dtype=None,
18891889

18901890
if np.prod(values.shape):
18911891
flat = values.ravel()
1892-
inferred_type = lib.infer_dtype(flat)
1892+
1893+
# try with just the first element; we just need to see if
1894+
# this is a datetime or not
1895+
inferred_type = lib.infer_dtype(flat[0:1])
18931896
if inferred_type in ['datetime', 'datetime64']:
18941897

18951898
# we have an object array that has been inferred as

vb_suite/indexing.py

+7
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,10 @@
167167

168168
frame_loc_dups = Benchmark('df2.loc[idx]', setup,
169169
start_date=datetime(2013, 1, 1))
170+
171+
setup = common_setup + """
172+
df = DataFrame(dict( A = [ 'foo'] * 1000000))
173+
"""
174+
175+
frame_iloc_big = Benchmark('df.iloc[:100,0]', setup,
176+
start_date=datetime(2013, 1, 1))

0 commit comments

Comments
 (0)