BUG: pd.Timedelta cannot handle unicode on Python 2 #11995

Closed
shoyer opened this Issue Jan 8, 2016 · 1 comment

Comments

Projects
None yet
2 participants
Member

shoyer commented Jan 8, 2016

This is on master:

In [1]: import pandas as pd

In [2]: pd.__version__
Out[2]: '0.17.1+179.g44e4c96'

In [3]: pd.Timedelta('1H')
Out[3]: Timedelta('0 days 01:00:00')

In [4]: pd.Timedelta(u'1H')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-9b0d9f7ba675> in <module>()
----> 1 pd.Timedelta(u'1H')

/Users/shoyer/dev/pandas/pandas/tslib.pyx in pandas.tslib.Timedelta.__new__ (pandas/tslib.c:39786)()
   2329             value = value.value
   2330         elif util.is_string_object(value):
-> 2331             value = np.timedelta64(parse_timedelta_string(value, False))
   2332         elif isinstance(value, timedelta):
   2333             value = convert_to_timedelta64(value,'ns',False)

/Users/shoyer/dev/pandas/pandas/tslib.pyx in pandas.tslib.parse_timedelta_string (pandas/tslib.c:46542)()
   2784         return NPY_NAT
   2785
-> 2786     for c in ts:
   2787
   2788         # skip whitespace / commas

TypeError: Expected str, got unicode```
Contributor

jreback commented Jan 8, 2016

hmm thought I could do that - guess I have to decode it first :(

jreback added this to the Next Major Release milestone Jan 8, 2016

@jreback jreback added a commit to jreback/pandas that referenced this issue Jan 8, 2016

@jreback jreback BUG: accept unicode in Timedelta constructor, #11995 3acd93d

@jreback jreback modified the milestone: 0.18.0, Next Major Release Jan 8, 2016

jreback closed this in #11997 Jan 8, 2016

@jreback jreback added a commit that referenced this issue Jan 8, 2016

@jreback jreback Merge pull request #11997 from jreback/td
BUG: accept unicode in Timedelta constructor, #11995
f2b083b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment