New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatibility between pandas.infer_freq and pandas.to_timedelta #14398
Comments
In [254]: dates = pd.bdate_range(start='2014-01-01', periods=10)
In [255]: pd.infer_freq(dates)
Out[255]: 'B' If you need to convert a frequency string into a In [253]: from pandas.tseries.frequencies import to_offset
In [256]: to_offset('D')
Out[256]: <Day>
In [257]: to_offset('2D')
Out[257]: <2 * Days>
In [258]: to_offset('B')
Out[258]: <BusinessDay> |
BTW, you can convert such an offset to a timedelta for certain types:
(or alternative |
Thank you for the comments! It makes sense now. |
A small, complete example of the issue
The output of
pd.infer_freq
is "D" whilepd.to_timedelta
expects "1D".Expected Output
delta = Timedelta('1 days 00:00:00')
Output of
pd.show_versions()
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 26.1.1
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.18.0
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None
The text was updated successfully, but these errors were encountered: