BUG: casting dt64 in DataFrame.reindex · Issue #39755 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
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