Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b7fcb54
CLN: remove unnecessary overriding in subclasses (#30875)
jbrockmendel Jan 10, 2020
6f2c509
DEPR: fix missing stacklevel in pandas.core.index deprecation (#30878)
jorisvandenbossche Jan 10, 2020
d1b9598
DOC: Encourage use of pre-commit in the docs (#30864)
gfyoung Jan 10, 2020
447a3b0
WEB: Removing Discourse links (#30890)
datapythonista Jan 10, 2020
03cdcb6
WEB: Remove from roadmap moving the docstring script (#30893)
datapythonista Jan 10, 2020
0b4bac7
TYP: typing annotations (#30901)
ShaharNaveh Jan 10, 2020
f887eb0
TYP: offsets (#30897)
jbrockmendel Jan 10, 2020
6e9651e
BUG: pickle files left behind by tm.round_trip_pickle (#30906)
jbrockmendel Jan 11, 2020
7f2948c
replace syntax with f-string (#30919)
HH-MWB Jan 11, 2020
939e7dd
CLN: F-strings (#30916)
dinasv Jan 11, 2020
b47a454
DOC: Fixture docs in pandas/conftest.py (#30917)
gfyoung Jan 11, 2020
75ecfa4
CLN: remove unnecesary _date_check_type (#30932)
jbrockmendel Jan 11, 2020
044559a
DOC: Fix SS03 docstring error (#30939)
galuhsahid Jan 12, 2020
28e909c
TYP: type up parts of series.py (#30761)
topper-123 Jan 12, 2020
4e2546d
STY: wrong placed space in strings (#30940)
ShaharNaveh Jan 12, 2020
45580a2
DOC: Fix whatsnew contributors section (#30926)
jschendel Jan 13, 2020
439d629
CI: numpydev changed double to single quote (#30952)
jbrockmendel Jan 13, 2020
46c2864
CLN: leftover ix checks (#30951)
jbrockmendel Jan 13, 2020
bbccf2d
DOC: Move import conventions from wiki to docs #30808 (#30888)
souvik3333 Jan 13, 2020
2c76d06
DOC: Move couple of deprecations whatsnew to correct section (#30961)
ryankarlos Jan 13, 2020
62d16ab
STY: concat strings that should not be seperated (#30942)
ShaharNaveh Jan 13, 2020
dd6e31a
REGR: Fixed hash_key=None for object values (#30900)
TomAugspurger Jan 13, 2020
bd63ece
CLN: remove no-op from indexing (#30934)
jbrockmendel Jan 13, 2020
7ba53f0
BUG: -1 to the power of pd.NA was returning -1 (#30960)
MarcoGorelli Jan 13, 2020
67fcdef
TYP: NDFrame.resample (#30947)
topper-123 Jan 13, 2020
993fdbe
DOC: whatsnew for 1.1 (#30972)
WillAyd Jan 13, 2020
6928327
CLN: misc cleanups (#30877)
jbrockmendel Jan 13, 2020
2bf0c9f
Compat for util.testing import (#30973)
TomAugspurger Jan 13, 2020
307137c
STY: concat strings (#30979)
ShaharNaveh Jan 13, 2020
2075539
Added small corrections to the test for interpolate limit_area (#30987)
cchwala Jan 13, 2020
8ff2ebd
STY: concat strings (#30991)
ShaharNaveh Jan 14, 2020
13b22fd
CLN: de-duplicate _getitem_scalar (#30992)
jbrockmendel Jan 14, 2020
0f048cb
CLN: remove geopandas compat code (#30909)
jbrockmendel Jan 14, 2020
b18024d
STY: Whitespaces placed at the beginning instead at the end of a line…
ShaharNaveh Jan 14, 2020
3471270
API: Disallow NaN in StringArray constructor (#30980)
TomAugspurger Jan 14, 2020
81d9636
BUG: ensure_datetime64ns with bigendian array (#30976)
jbrockmendel Jan 14, 2020
7d24b1c
docs: correct wrong result in pd.NA ** 0
tsvikas Jan 14, 2020
33d198d
Merge branch '1.0.x' into docs-na-pow
tsvikas Jan 14, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: ensure_datetime64ns with bigendian array (#30976)
  • Loading branch information
jbrockmendel authored and jreback committed Jan 14, 2020
commit 81d96369753f5244f011e41bf12b439a53f68852
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Numeric

Conversion
^^^^^^^^^^

- Bug in :class:`Series` construction from NumPy array with big-endian ``datetime64`` dtype (:issue:`29684`)
-
-

Expand Down
5 changes: 5 additions & 0 deletions pandas/_libs/tslibs/conversion.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def ensure_datetime64ns(arr: ndarray, copy: bool=True):

shape = (<object>arr).shape

if (<object>arr).dtype.byteorder == ">":
# GH#29684 we incorrectly get OutOfBoundsDatetime if we dont swap
dtype = arr.dtype
arr = arr.astype(dtype.newbyteorder("<"))

ivalues = arr.view(np.int64).ravel()

result = np.empty(shape, dtype=NS_DTYPE)
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,15 @@ def test_constructor_with_naive_string_and_datetimetz_dtype(self, arg):
expected = Series(pd.Timestamp(arg)).dt.tz_localize("CET")
tm.assert_series_equal(result, expected)

def test_constructor_datetime64_bigendian(self):
# GH#30976
ms = np.datetime64(1, "ms")
arr = np.array([np.datetime64(1, "ms")], dtype=">M8[ms]")

result = Series(arr)
expected = Series([Timestamp(ms)])
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("interval_constructor", [IntervalIndex, IntervalArray])
def test_construction_interval(self, interval_constructor):
# construction from interval & array of intervals
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/tslibs/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ def test_length_zero_copy(dtype, copy):
assert result.base is (None if copy else arr)


def test_ensure_datetime64ns_bigendian():
# GH#29684
arr = np.array([np.datetime64(1, "ms")], dtype=">M8[ms]")
result = conversion.ensure_datetime64ns(arr)

expected = np.array([np.datetime64(1, "ms")], dtype="M8[ns]")
tm.assert_numpy_array_equal(result, expected)


class SubDatetime(datetime):
pass

Expand Down