Handle NaN in array_with_unit_to_datetime
State: closed

closes https://github.com/pandas-dev/pandas/issues/48610

Missing values in arrays can either be NaT (for integer types) or NaN (for
floating types).  Make sure to also handle the latter.  This fixes all
failing tests.


Labels:
name: Datetime
description: Datetime data dtype
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
name: Stale

Comments:
Does this fix an existing Github issue? Would need tests as well
The existing tests already cover it perfectly.

You mentioned 

> This fixes all failing tests

What tests were failing? 
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:RISCV/python-pandas:test-py310/standard/riscv64

=========================== short test summary info ============================
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[trade_time]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[date]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[datetime]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[sold_at]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[modified]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[timestamp]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_convert_dates_infer[timestamps]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_date_unit[s]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_date_unit[ms]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_date_unit[us]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_to_json_from_json_columns_dtypes[split]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_to_json_from_json_columns_dtypes[records]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_to_json_from_json_columns_dtypes[index]
FAILED pandas/tests/io/json/test_pandas.py::TestPandasContainer::test_to_json_from_json_columns_dtypes[columns]
FAILED pandas/tests/tools/test_to_datetime.py::TestToDatetimeUnit::test_to_datetime_unit_with_nulls[nan]
= 15 failed, 143030 passed, 9020 skipped, 1047 xfailed, 6 xpassed, 18 warnings in 16656.29s (4:37:36) =

So this is related to https://github.com/pandas-dev/pandas/issues/48610?
Yes.

$ python3
Python 3.10.7 (main, Sep 11 2022, 08:41:56) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.array([np.nan]).astype("i8")
array([9223372036854775807])

This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.
Would https://github.com/pandas-dev/pandas/pull/50183/files also address the issue?
Yes, it does.

https://build.opensuse.org/project/monitor/home:Andreas_Schwab:riscv:python
thanks @andreas-schwab