pd.Timedelta is a great addition, thanks!
Is it the intended behavior of pd.Timedelta to only accept np.int64, python ints, and python floats? I ran into this when I tried to construct a list of pd.Timedeltas from the np.int32 array returned by pd.DatetimeIndex.dayofyear.
>>> import pandas as pd >>> import numpy as np >>> pd.Timedelta(days=np.int64(1)) Timedelta('1 days 00:00:00') >>> pd.Timedelta(days=np.int32(1)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pandas/tslib.pyx", line 1638, in pandas.tslib.Timedelta.__new__ (pandas/tslib.c:27693) ValueError: cannot construct a TimeDelta from the passed arguments, allowed keywords are [days, seconds, microseconds, milliseconds, minutes, hours, weeks] >>> pd.Timedelta(days=np.int16(1)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pandas/tslib.pyx", line 1638, in pandas.tslib.Timedelta.__new__ (pandas/tslib.c:27693) ValueError: cannot construct a TimeDelta from the passed arguments, allowed keywords are [days, seconds, microseconds, milliseconds, minutes, hours, weeks] >>> pd.Timedelta(days=np.float64(1)) Timedelta('1 days 00:00:00') >>> pd.Timedelta(days=np.float32(1)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pandas/tslib.pyx", line 1638, in pandas.tslib.Timedelta.__new__ (pandas/tslib.c:27693) ValueError: cannot construct a TimeDelta from the passed arguments, allowed keywords are [days, seconds, microseconds, milliseconds, minutes, hours, weeks] >>> pd.Timedelta(days=1) Timedelta('1 days 00:00:00') >>> pd.Timedelta(days=1.0) Timedelta('1 days 00:00:00')
Here's my version info:
>>> pd.show_versions() INSTALLED VERSIONS ------------------ commit: None python: 2.7.6.final.0 python-bits: 64 OS: Linux OS-release: 2.6.32-431.17.1.el6.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 pandas: 0.15.1 nose: 1.3.4 Cython: 0.21 numpy: 1.9.1 scipy: 0.14.0 statsmodels: None IPython: 2.3.0 sphinx: 1.2.3 patsy: None dateutil: 2.2 pytz: 2014.9 bottleneck: None tables: None numexpr: None matplotlib: 1.4.0 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: None httplib2: None apiclient: None rpy2: None sqlalchemy: 0.9.7 pymysql: 0.6.2.None psycopg2: None
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4