You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.The text was updated successfully, but these errors were encountered: