Skip to content

BUG: casting dt64 in DataFrame.reindex #39755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbrockmendel opened this issue Feb 11, 2021 · 0 comments · Fixed by #39759
Closed

BUG: casting dt64 in DataFrame.reindex #39755

jbrockmendel opened this issue Feb 11, 2021 · 0 comments · Fixed by #39759
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timedelta Timedelta data type
Milestone

Comments

@jbrockmendel
Copy link
Member

import numpy as np
import pandas as pd

mi = pd.MultiIndex.from_product([list("ABCDE"), range(2)])
dti = pd.date_range("2016-01-01", periods=10)
ser = pd.Series(dti, index=mi)
df = ser.unstack()

index = df.index.append(pd.Index([1]))
columns = df.columns.append(pd.Index(["foo"]))
axes = {"index": index, "columns": columns}

fv = np.timedelta64("NaT", "ns")

res = df.reindex(fill_value=fv, **axes)

>>> res
>>> res
                     0                    1 foo
A  1451606400000000000  1451692800000000000 NaT
B  1451779200000000000  1451865600000000000 NaT
C  1451952000000000000  1452038400000000000 NaT
D  1452124800000000000  1452211200000000000 NaT
E  1452297600000000000  1452384000000000000 NaT
1                  NaT                  NaT NaT

The underlying problem here is numpy/numpy#12550

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 11, 2021
@jreback jreback added this to the 1.3 milestone Feb 12, 2021
@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timedelta Timedelta data type and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants