diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 7b9efd7f593dd..eb4bd0e2eb010 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -363,6 +363,7 @@ Datetimelike ^^^^^^^^^^^^ - :meth:`DatetimeIndex.map` with ``na_action="ignore"`` now works as expected. (:issue:`51644`) - Bug in :class:`DateOffset` which had inconsistent behavior when multiplying a :class:`DateOffset` object by a constant (:issue:`47953`) +- Bug in :func:`concat` raises ``AttributeError`` when concate ``None`` dtype DataFrame with ``timestamp`` dtype DataFrame. (:issue:`52093`) - Bug in :func:`date_range` when ``freq`` was a :class:`DateOffset` with ``nanoseconds`` (:issue:`46877`) - Bug in :meth:`Timestamp.date`, :meth:`Timestamp.isocalendar`, :meth:`Timestamp.timetuple`, and :meth:`Timestamp.toordinal` were returning incorrect results for inputs outside those supported by the Python standard library's datetime module (:issue:`53668`) - Bug in :meth:`Timestamp.round` with values close to the implementation bounds returning incorrect results instead of raising ``OutOfBoundsDatetime`` (:issue:`51494`) diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index f11c909a5df41..761659760bce8 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -26,6 +26,7 @@ BlockPlacement, BlockValuesRefs, ) +from pandas._libs.tslibs import Timestamp from pandas.errors import PerformanceWarning from pandas.util._decorators import cache_readonly from pandas.util._exceptions import find_stack_level @@ -2389,7 +2390,7 @@ def _preprocess_slice_or_indexer( def make_na_array(dtype: DtypeObj, shape: Shape, fill_value) -> ArrayLike: if isinstance(dtype, DatetimeTZDtype): # NB: exclude e.g. pyarrow[dt64tz] dtypes - i8values = np.full(shape, fill_value._value) + i8values = np.full(shape, Timestamp(fill_value)._value) return DatetimeArray(i8values, dtype=dtype) elif is_1d_only_ea_dtype(dtype): diff --git a/pandas/tests/reshape/concat/test_concat.py b/pandas/tests/reshape/concat/test_concat.py index dc14e6e74302e..28f3995d1102e 100644 --- a/pandas/tests/reshape/concat/test_concat.py +++ b/pandas/tests/reshape/concat/test_concat.py @@ -826,3 +826,14 @@ def test_concat_mismatched_keys_length(): concat((x for x in sers), keys=(y for y in keys), axis=1) with tm.assert_produces_warning(FutureWarning, match=msg): concat((x for x in sers), keys=(y for y in keys), axis=0) + + +def test_concat_none_with_datetime(): + # GH 52093 + df1 = DataFrame([{"A": None}], dtype="datetime64[ns, UTC]") + df2 = DataFrame([{"A": pd.to_datetime("1990-12-20 00:00:00+00:00")}]) + result = concat([df1, df2]) + expected = DataFrame( + [{"A": None}, {"A": pd.to_datetime("1990-12-20 00:00:00+00:00")}], index=[0, 0] + ) + tm.assert_frame_equal(result, expected)