Skip to content

Commit

Permalink
TST: tests for inconsistent indexing with datetimes (pandas-dev#20550)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcontesti authored and david-liu-brattle-1 committed Jun 18, 2018
1 parent 88d0fa3 commit cf817ff
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,25 @@ def test_setitem_single_column_mixed_datetime(self):
# pytest.raises(
# Exception, df.loc.__setitem__, ('d', 'timestamp'), [nan])

def test_setitem_mixed_datetime(self):
# GH 9336
expected = DataFrame({'a': [0, 0, 0, 0, 13, 14],
'b': [pd.datetime(2012, 1, 1),
1,
'x',
'y',
pd.datetime(2013, 1, 1),
pd.datetime(2014, 1, 1)]})
df = pd.DataFrame(0, columns=list('ab'), index=range(6))
df['b'] = pd.NaT
df.loc[0, 'b'] = pd.datetime(2012, 1, 1)
df.loc[1, 'b'] = 1
df.loc[[2, 3], 'b'] = 'x', 'y'
A = np.array([[13, np.datetime64('2013-01-01T00:00:00')],
[14, np.datetime64('2014-01-01T00:00:00')]])
df.loc[[4, 5], ['a', 'b']] = A
assert_frame_equal(df, expected)

def test_setitem_frame(self):
piece = self.frame.loc[self.frame.index[:2], ['A', 'B']]
self.frame.loc[self.frame.index[-2]:, ['A', 'B']] = piece.values
Expand Down

0 comments on commit cf817ff

Please sign in to comment.