Closed
Description
dti = pd.date_range("2016-01-01", periods=5)
df = pd.DataFrame(np.random.randn(5, 2), index=dti, columns=["A", "B"])
>>> df.loc[4:6, "A"]
TypeError: cannot do slice indexing on DatetimeIndex with these indexers [4] of type int
>>> df.loc[4:6, "A"] = 0
# works as if we did df.iloc[4:6, 0] = 0
In this case there are plenty of alternatives that amount to doing df["A"].iloc[4:6] = 0
, but this isnt robust to mixed-dtype frames, so I'm not sure if we have a supported way of doing this correctly.
Metadata
Metadata
Assignees
Labels
No labels