Skip to content

Commit 07b772a

Browse files
committed
use the numpy results if we can to avoid repeating the computation just to create the object
1 parent a110be9 commit 07b772a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pandas/tseries/base.py

+5
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ def _nat_new(self, box=True):
330330
def map(self, f):
331331
try:
332332
result = f(self)
333+
334+
# Try to use this result if we can
335+
if isinstance(result, np.ndarray):
336+
self._shallow_copy(result)
337+
333338
if not isinstance(result, Index):
334339
raise TypeError
335340
return result

0 commit comments

Comments
 (0)