We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a8cabb8 commit 56fdc1fCopy full SHA for 56fdc1f
pandas/tests/frame/test_timeseries.py
@@ -366,6 +366,19 @@ def test_operation_on_NaT(self):
366
exp = pd.Series([pd.NaT], index=["foo"])
367
tm.assert_series_equal(res, exp)
368
369
+ def test_datetime_assignment_with_NaT_and_diff_time_units(self):
370
+ # GH 7492
371
+ data_ns = np.array([1, 'nat'], dtype='datetime64[ns]')
372
+ result = pd.Series(data_ns).to_frame()
373
+ result['new'] = data_ns
374
+ expected = pd.DataFrame({0: data_ns, 'new': data_ns})
375
+ tm.assert_frame_equal(result, expected)
376
+ # OutOfBoundsDatetime error shouldn't occur
377
+ data_s = np.array([1, 'nat'], dtype='datetime64[s]')
378
+ result['new'] = data_s
379
+ expected = pd.DataFrame({0: data_ns, 'new': data_s})
380
381
+
382
383
if __name__ == '__main__':
384
import nose
0 commit comments