Skip to content

Commit f01732a

Browse files
committed
few corrections tests with to_datetime
1 parent 99e26a5 commit f01732a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pandas/core/indexes/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def __new__(cls, data=None,
332332
if not (is_datetime64_dtype(data) or is_datetimetz(data) or
333333
is_integer_dtype(data)):
334334
data = tools.to_datetime(data, dayfirst=dayfirst,
335-
yearfirst=yearfirst)
335+
unit='ns', yearfirst=yearfirst)
336336

337337
if issubclass(data.dtype.type, np.datetime64) or is_datetimetz(data):
338338

pandas/core/tools/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def check_numerical_arg():
463463
.format(type(arg)))
464464
else:
465465
if (format is None and check_numerical_arg() and
466-
not isinstance(arg, (DataFrame,))):
466+
not isinstance(arg, (DataFrame,)) and np.asarray(arg).size):
467467
raise ValueError("a unit is required in case of numerical arg")
468468

469469
# handle origin

pandas/tests/test_resample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ def test_nanosecond_resample_error(self):
16941694
start = 1443707890427
16951695
exp_start = 1443707890400
16961696
indx = pd.date_range(
1697-
start=pd.to_datetime(start),
1697+
start=pd.to_datetime(start, unit='ns'),
16981698
periods=10,
16991699
freq='100n'
17001700
)
@@ -1703,7 +1703,7 @@ def test_nanosecond_resample_error(self):
17031703
result = r.agg('mean')
17041704

17051705
exp_indx = pd.date_range(
1706-
start=pd.to_datetime(exp_start),
1706+
start=pd.to_datetime(exp_start, unit='ns'),
17071707
periods=10,
17081708
freq='100n'
17091709
)

0 commit comments

Comments
 (0)