Skip to content

Commit 38aae73

Browse files
committed
Merge branch 'custombd' of https://github.com/sinhrks/pandas into sinhrks-custombd
Conflicts: doc/source/v0.14.1.txt
2 parents 4be3899 + 55b05e7 commit 38aae73

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

doc/source/v0.14.1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ Bug Fixes
8888
- Bug in inferred_freq results in None for eastern hemisphere timezones (:issue:`7310`)
8989
- Bug in ``Easter`` returns incorrect date when offset is negative (:issue:`7195`)
9090
- Bug in broadcasting with ``.div``, integer dtypes and divide-by-zero (:issue:`7325`)
91+
- Bug in ``CustomBusinessDay.apply`` raiases ``NameError`` when ``np.datetime64`` object is passed (:issue:`7196`)

pandas/tseries/offsets.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ def apply(self, other):
528528

529529
# Distinguish input cases to enhance performance
530530
if isinstance(other, datetime):
531-
dtype = type(other)
532531
date_in = other
533532
np_dt = np.datetime64(date_in.date())
534533

@@ -547,7 +546,6 @@ def apply(self, other):
547546
return as_timestamp(result)
548547

549548
elif isinstance(other, np.datetime64):
550-
dtype = other.dtype
551549
date_in = other
552550
np_day = date_in.astype('datetime64[D]')
553551
np_time = date_in - np_day
@@ -556,7 +554,7 @@ def apply(self, other):
556554
busdaycal=self.busdaycalendar)
557555

558556
if not self.normalize:
559-
result = np_day_incr + np_time
557+
result = np_incr_dt + np_time
560558
else:
561559
result = np_incr_dt
562560

pandas/tseries/tests/test_offsets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ class TestCustomBusinessDay(Base):
382382

383383
def setUp(self):
384384
self.d = datetime(2008, 1, 1)
385+
self.nd = np.datetime64('2008-01-01 00:00:00Z')
385386

386387
_skip_if_no_cday()
387388
self.offset = CDay()
@@ -417,6 +418,7 @@ def test_hash(self):
417418

418419
def testCall(self):
419420
self.assertEqual(self.offset2(self.d), datetime(2008, 1, 3))
421+
self.assertEqual(self.offset2(self.nd), datetime(2008, 1, 3))
420422

421423
def testRAdd(self):
422424
self.assertEqual(self.d + self.offset2, self.offset2 + self.d)

0 commit comments

Comments
 (0)