You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All numerical types now need a unit in to_datetime call.
* Update tests
* Add bool verification in tslib.pyx
* Bug correction with bool and unit in ['ms', 'us', 's', 'D']
* to_datetime(True, unit='ms') did run without error
* to_datetime(True, unit='ms', errors='ignore') returned None
Issue: pandas-dev#15836
/home/anthony/src/pandas/pandas/core/tools/datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, box, format, exact, unit, infer_datetime_format, origin)
161
+
461 elif ((not isinstance(arg, DataFrame)) and
162
+
462 (check_numerical_arg() and unit is None and format is None)):
163
+
--> 463 raise ValueError("a unit is required in case of numerical arg")
164
+
464
165
+
465 # handle origin
166
+
167
+
ValueError: a unit is required in case of numerical arg
/home/anthony/src/pandas/pandas/core/tools/datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, box, format, exact, unit, infer_datetime_format, origin)
187
+
533 result = _convert_listlike(arg, box, format)
188
+
534 else:
189
+
--> 535 result = _convert_listlike(np.array([arg]), box, format)[0]
190
+
536
191
+
537 return result
192
+
193
+
/home/anthony/src/pandas/pandas/core/tools/datetimes.py in _convert_listlike(arg, box, format, name, tz)
194
+
374 arg = getattr(arg, 'values', arg)
195
+
375 result = tslib.array_with_unit_to_datetime(arg, unit,
196
+
--> 376 errors=errors)
197
+
377 if box:
198
+
378 if errors == 'ignore':
199
+
200
+
/home/anthony/src/pandas/pandas/_libs/tslib.pyx in pandas._libs.tslib.array_with_unit_to_datetime()
201
+
2210
202
+
2211
203
+
-> 2212 cpdef array_with_unit_to_datetime(ndarray values, unit, errors='coerce'):
204
+
2213 """
205
+
2214 convert the ndarray according to the unit
206
+
207
+
/home/anthony/src/pandas/pandas/_libs/tslib.pyx in pandas._libs.tslib.array_with_unit_to_datetime()
208
+
2246 raise TypeError("{0} is not convertible to datetime"
0 commit comments