Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: tests for inconsistent indexing with datetimes #20550

Merged
merged 5 commits into from
May 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,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