Skip to content

Commit d1008e8

Browse files
committed
BUG: setitem with Timestamp #2155
1 parent db9446f commit d1008e8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pandas/tseries/index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ def insert(self, loc, item):
12551255
-------
12561256
new_index : Index
12571257
"""
1258-
if type(item) == datetime:
1258+
if isinstance(item, datetime):
12591259
item = _to_m8(item)
12601260

12611261
new_index = np.concatenate((self[:loc].asi8,

pandas/tseries/tests/test_timeseries.py

+10
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,16 @@ def test_frame_fillna_limit(self):
320320
expected.values[:3] = np.nan
321321
tm.assert_frame_equal(result, expected)
322322

323+
def test_frame_setitem_timestamp(self):
324+
#2155
325+
columns = DatetimeIndex(start='1/1/2012', end='2/1/2012',
326+
freq=datetools.bday)
327+
index = range(10)
328+
data = DataFrame(columns=columns, index=index)
329+
t = datetime(2012, 11, 1)
330+
ts = Timestamp(t)
331+
data[ts] = np.nan #works
332+
323333
def test_sparse_series_fillna_limit(self):
324334
index = np.arange(10)
325335
s = Series(np.random.randn(10), index=index)

0 commit comments

Comments
 (0)