Skip to content

Commit b13a1cc

Browse files
committed
TST: handle #2804 bug in cython
1 parent 0329d96 commit b13a1cc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pandas/tseries/index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def __new__(cls, data=None,
228228
offset = data.offset
229229
verify_integrity = False
230230
else:
231-
if data.dtype != _NS_DTYPE and data.size:
231+
if data.dtype != _NS_DTYPE:
232232
subarr = tslib.cast_to_nanoseconds(data)
233233
else:
234234
subarr = data
@@ -1138,7 +1138,7 @@ def get_loc(self, key):
11381138

11391139
if isinstance(key, time):
11401140
return self.indexer_at_time(key)
1141-
1141+
11421142
try:
11431143
stamp = Timestamp(key, tz=self.tz)
11441144
return self._engine.get_loc(stamp)

pandas/tslib.pyx

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None):
8181
# Adjust datetime64 timestamp, recompute datetimestruct
8282
pos = trans.searchsorted(arr[i]) - 1
8383
inf = tz._transition_info[pos]
84-
84+
8585
pandas_datetime_to_datetimestruct(arr[i] + deltas[pos],
8686
PANDAS_FR_ns, &dts)
8787
result[i] = datetime(dts.year, dts.month, dts.day, dts.hour,
@@ -914,6 +914,9 @@ def cast_to_nanoseconds(ndarray arr):
914914
result = np.empty(shape, dtype='M8[ns]')
915915
iresult = result.ravel().view(np.int64)
916916

917+
if len(iresult) == 0:
918+
return result
919+
917920
unit = get_datetime64_unit(arr.flat[0])
918921
if unit == 3:
919922
raise ValueError('NumPy 1.6.1 business freq not supported')

0 commit comments

Comments
 (0)