Commit 785f407
committed
ENH: Cast ndarray-like datetime64 arrays to Index properly
It turns out that the ndarray-like arrays of dtype datetime64 were
not being properly cast to an Index, because -- due to a bug with
np.datetime64 -- calling np.asarray(x, dtype=object) if x is an
ndarray of type datetime64 results in an *integer* array.
This PR adds tests and a work around to pd.Index.__new__.
Related #54601 parent 8d209de commit 785f407
2 files changed
+13
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
151 | 154 | | |
152 | 155 | | |
153 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
180 | 182 | | |
181 | | - | |
| 183 | + | |
182 | 184 | | |
183 | | - | |
184 | | - | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
| |||
447 | 452 | | |
448 | 453 | | |
449 | 454 | | |
450 | | - | |
| 455 | + | |
451 | 456 | | |
452 | 457 | | |
453 | 458 | | |
| |||
0 commit comments