Skip to content

BUG: concat_{categorical, compat} leads to erroneous result on non-ns datetime-EA  #33331

Open
@xhochy

Description

@xhochy

Code to reproduce:

import numpy as np
import pandas as pd

np_datetimes = np.array([datetime.date(2010, 1, 1)], dtype="datetime64[D]")
other = pd.array(["a", "b"], dtype="category")
pd.core.dtypes.concat.concat_categorical([np_datetimes, other])
# outputs:
#   array([Timestamp('1970-01-01 00:00:00.000014610'), 'a', 'b'], dtype=object)
# expected either one of
#   a) array([Timestamp('2010-01-01 00:00:00'), 'a', 'b'], dtype=object)
#   b) array([datetime.date(2010, 1, 1), 'a', 'b'], dtype=object)

This happens as concat_datetime / _convert_datetimelike_to_object assumes that datetimes are nanoseconds only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugExtensionArrayExtending pandas with custom dtypes or arrays.Needs TestsUnit test(s) needed to prevent regressionsNon-Nanodatetime64/timedelta64 with non-nanosecond resolutionReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions