作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试着理解为什么
print(pd.Timestamp("2015-01-01") - pd.DateOffset(day=1))
pd.Timestamp("2014-12-31")
最佳答案
您可以查看 pandas.tseries.offsets.DateOffset
:
*kwds
Temporal parameter that add to or replace the offset value.
Parameters that add to the offset (like Timedelta):
- years
- months
- weeks
- days
- hours
- minutes
- seconds
- microseconds
- nanoseconds
Parameters that replace the offset value:
- year
- month
- day
- weekday
- hour
- minute
- second
- microsecond
- nanosecond
print(pd.Timestamp("2015-01-01") - pd.DateOffset(days=1))
2014-12-31 00:00:00
另一种解决方案:
print(pd.Timestamp("2015-01-01") - pd.offsets.Day(1))
2014-12-31 00:00:00
也可以减去
Timedelta
:
print(pd.Timestamp("2015-01-01") - pd.Timedelta(1, unit='d'))
关于date - Pandas DateOffset,倒退一天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36764487/
python 有办法反向执行 foreach 吗?我希望同时执行 filter() (或列表理解)和反转列表,这样我就可以避免单独执行(我怀疑这会更慢)。我正在使用 python 2.4(不幸的是我不
我有一个文本文件,其中随机出现了很多字符串@STRING_A,我有兴趣编写一个仅删除其中一些字符串的简短脚本。特别是扫描文件的文件,一旦找到以该字符串开头的行,例如 @STRING_A 然后检查向后
我一直在阅读有关使用 dns-prefetch 和预连接的信息。显然应该使用它们,因为一点一滴都有帮助。 dns-prefetch 比 preconnect 有更好的跨浏览器支持。所以我的问题是,如果
我想用 joda 时间回到 1 年前,但我不想从 2010 年 2 月 15 日到 2009 年 2 月 15 日,而是,如果 2010 年 2 月 15 日是星期一,那么我想去最近的 2009 年星
我是一名优秀的程序员,十分优秀!