Skip to content

Commit 01cbaea

Browse files
authored
PERF: IntervalArray.from_tuples (#50620)
1 parent 76c39d5 commit 01cbaea

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

asv_bench/benchmarks/array.py

+9
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def time_from_integer_array(self):
4444
pd.array(self.values_integer, dtype="Int64")
4545

4646

47+
class IntervalArray:
48+
def setup(self):
49+
N = 10_000
50+
self.tuples = [(i, i + 1) for i in range(N)]
51+
52+
def time_from_tuples(self):
53+
pd.arrays.IntervalArray.from_tuples(self.tuples)
54+
55+
4756
class StringArray:
4857
def setup(self):
4958
N = 100_000

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ Performance improvements
775775
- Performance improvement for :func:`concat` with extension array backed indexes (:issue:`49128`, :issue:`49178`)
776776
- Reduce memory usage of :meth:`DataFrame.to_pickle`/:meth:`Series.to_pickle` when using BZ2 or LZMA (:issue:`49068`)
777777
- Performance improvement for :class:`~arrays.StringArray` constructor passing a numpy array with type ``np.str_`` (:issue:`49109`)
778+
- Performance improvement in :meth:`~arrays.IntervalArray.from_tuples` (:issue:`50620`)
778779
- Performance improvement in :meth:`~arrays.ArrowExtensionArray.factorize` (:issue:`49177`)
779780
- Performance improvement in :meth:`~arrays.ArrowExtensionArray.__setitem__` when key is a null slice (:issue:`50248`)
780781
- Performance improvement in :class:`~arrays.ArrowExtensionArray` comparison methods when array contains NA (:issue:`50524`)

pandas/core/arrays/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ def from_tuples(
608608
left = right = data
609609

610610
for d in data:
611-
if isna(d):
611+
if not isinstance(d, tuple) and isna(d):
612612
lhs = rhs = np.nan
613613
else:
614614
name = cls.__name__

0 commit comments

Comments
 (0)