Closed
Description
pd.DataFrame.asfreq
seems to silently drop rows when the data is not sorted.
d=pd.DataFrame(range(3), index=pd.to_datetime(["2021-01-01", "2021-03-01", "2021-02-01"])).asfreq("MS")
d
# output:
# 2021-01-01 0
# 2021-02-01 2
Silent data loss is very dangerous in data analysis as it's hard to detect.
Expected behavior:
- an exception, because dropping rows is not useful
- or automatic sorting (with possibly a parameter in asfreq to be explicit)
INSTALLED VERSIONS
------------------
commit : 9d598a5e1eee26df95b3910e3f2934890d062caa
python : 3.8.5.final.0
pandas : 1.2.1
numpy : 1.19.2