http://stackoverflow.com/questions/15769706/converting-a-list-in-a-dict-to-a-series/15770083?noredirect=1#comment22416395_15770083
Comment From: ghost
related #3000, #3005 , it's a general pattern, ABCs did not see heavy use when pandas was in it's formative stage and so it's type-directed behaviour is too strict.
Comment From: jreback
yep....also need to accept this in the constructors (as well as output-formatters)
maybe should have a function to basically do the test isinstance(obj,list)
(which sometimes needs a tuple sometimes not), so maybe modify
_is_sequence_like
a bit
Comment From: ghost
the opt-in register() mechanism of the ABCs is pretty useful, just need to be careful of sharp corners: strings are sequences of-course, also #2978
Comment From: jreback
actually this is a bit more complicated, the problem is that a Timestamp
is a sequence as well! (and we often have to do some checking to avoid treating it like a list); np.scalar
I think should be redefined a bit (there is a routine somewhere in the cython code to do scalar testing in any event...should be fixed/consolidated as well)
Comment From: ghost
what?! how is Timestamp a sequence?
In [39]: t=Timestamp("2000-1-1")
In [40]: t[0]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-40-d0a24a012877> in <module>()
----> 1 t[0]
TypeError: 'Timestamp' object does not support indexing
In [41]: list(t)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-41-f57fd3c9bd0b> in <module>()
----> 1 list(t)
TypeError: 'Timestamp' object is not iterable
In [42]: import collections
In [43]: isinstance(t,collections.Sequence)
Out[43]: False
Comment From: jreback
sorry...meant that it isn't a scalar (though we treat it like one)
In [4]: np.isscalar(1)
Out[4]: True
In [5]: np.isscalar(pd.Timestamp('20010101'))
Out[5]: False
Comment From: jtratner
@jreback maybe this is silly, but why is the way that it prints actually wrong? Is there another example where this would matter? [clearly, I'm going through earlier bug reports]
Comment From: jreback
no the issue here is this
is you have a list of lists then the DataFrame constructor works fine
but if its a list-of-sequencers that are not lists but act like lists (eg collections.Sequence) then it doesn't work
this used to work when we used np.asarray but for various reasons the conversions are now a bit more 'manual'
so this is actually pretty easy to just accept a collections.Sequence in the constructors
Comment From: WillAyd
Closed due to age and ambiguity. If there is a reproducible example for issue feel free to reopen