gpt4 book ai didi

python - pandas 时间戳 - dateoffset 的错误结果

转载 作者:行者123 更新时间:2023-12-01 04:23:13 24 4
gpt4 key购买 nike

奇怪的是:

In[]:  import pandas as pd
pd.Timestamp('2015-10-10') - pd.DateOffset(month=1)
Out[]: Timestamp('2015-01-10 00:00:00')

我做错了什么?

附注:

pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-63-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.16.2
nose: 1.3.7
Cython: 0.23.3
numpy: 1.9.2
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.0
sphinx: 1.3.1
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.4
bottleneck: 1.0.0
tables: 3.2.0
numexpr: 2.4.3
matplotlib: 1.4.3
openpyxl: 1.8.5
xlrd: 0.9.3
xlwt: 1.0.0
xlsxwriter: 0.7.3
lxml: 3.4.4
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.5
pymysql: None
psycopg2: None

最佳答案

您可能想要这个:

>>> pd.Timestamp('2015-10-10') - pd.DateOffset(month=9)
Timestamp('2015-09-10 00:00:00', tz=None)

这可能对你来说更好:

>>> pd.Timestamp('2015-10-10') - pd.DateOffset(months=1)
Timestamp('2015-09-10 00:00:00', tz=None)

您正在设置月份,但您想要设置月份。分钟差异。

关于python - pandas 时间戳 - dateoffset 的错误结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33447988/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com