-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explodegood first issue
Description
Code Sample, a copy-pastable example if possible
In [40]: a = pd.DataFrame({"A": pd.array(['2000'], dtype='datetime64[ns]')})
In [41]: b = pd.DataFrame({"A": pd.array([1.0], dtype='float64')})
In [42]: pd.concat([a.iloc[:0], b.iloc[:0]])['A'].dtype
Out[42]: dtype('<M8[ns]')
Problem description
The return dtype of concatentating a float64 and datetime64[ns] should be object dtype. That's typically the case when both are non-empty
In [45]: pd.concat([a, b])['A'].dtype
Out[45]: dtype('O')
But when either is empty, we get incorrect results
In [42]: pd.concat([a.iloc[:0], b.iloc[:0]])['A'].dtype
Out[42]: dtype('<M8[ns]')
In [43]: pd.concat([a.iloc[:0], b])['A'].dtype
Out[43]: dtype('float64')
In [44]: pd.concat([a, b.iloc[:0]])['A'].dtype
Out[44]: dtype('<M8[ns]')
All of those should be object dtype.
mlondschien and peetacho
Metadata
Metadata
Assignees
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeConcat, Merge/Join, Stack/Unstack, Explodegood first issue