|
39 | 39 | from pandas._typing import ArrayLike
|
40 | 40 | from pandas.core import algorithms
|
41 | 41 | from pandas.core.algorithms import unique
|
| 42 | +from pandas.arrays import IntegerArray |
42 | 43 |
|
43 | 44 | # ---------------------------------------------------------------------
|
44 | 45 | # types used in annotations
|
@@ -316,7 +317,16 @@ def _convert_listlike_datetimes(
|
316 | 317 | if format is not None:
|
317 | 318 | raise ValueError("cannot specify both format and unit")
|
318 | 319 | arg = getattr(arg, "values", arg)
|
319 |
| - result, tz_parsed = tslib.array_with_unit_to_datetime(arg, unit, errors=errors) |
| 320 | + # GH 30050 pass an ndarray to tslib.array_with_unit_to_datetime |
| 321 | + # because it expects an ndarray argument |
| 322 | + if isinstance(arg, IntegerArray): |
| 323 | + arg_np = np.array(arg[np.logical_not(arg._mask)],dtype=type(arg[0])) |
| 324 | + result_np, tz_parsed = tslib.array_with_unit_to_datetime(arg_np, unit, errors=errors) |
| 325 | + result = np.empty(arg.shape[0],dtype='datetime64[' + unit + ']') |
| 326 | + result[arg._mask] = np.datetime64('nat') |
| 327 | + result[np.logical_not(arg._mask)] = result_np |
| 328 | + else: |
| 329 | + result, tz_parsed = tslib.array_with_unit_to_datetime(arg, unit, errors=errors) |
320 | 330 | if errors == "ignore":
|
321 | 331 | from pandas import Index
|
322 | 332 |
|
|
0 commit comments