<p dir="auto">When I pass cursor as data to DataFrame constructor an error occurs.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cursor = sqlite.execute(sql)
pd.DataFrame(cursor)


/usr/lib/python3/dist-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    255                                          copy=copy)
    256         elif isinstance(data, collections.Iterator):
--&gt; 257             raise TypeError(&quot;data argument can't be an iterator&quot;)
    258         else:
    259             try:

TypeError: data argument can't be an iterator"><pre class="notranslate"><code class="notranslate">cursor = sqlite.execute(sql)
pd.DataFrame(cursor)


/usr/lib/python3/dist-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    255                                          copy=copy)
    256         elif isinstance(data, collections.Iterator):
--&gt; 257             raise TypeError("data argument can't be an iterator")
    258         else:
    259             try:

TypeError: data argument can't be an iterator
</code></pre></div>
<p dir="auto">But normal generators is accepted</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def gen():
    yield (1,2,3)
    yield (4,5,6)
    yield (7,8,9)

pd.DataFrame(gen())
Out[171]: 
   0  1  2
0  1  2  3
1  4  5  6
2  7  8  9"><pre class="notranslate"><code class="notranslate">def gen():
    yield (1,2,3)
    yield (4,5,6)
    yield (7,8,9)

pd.DataFrame(gen())
Out[171]: 
   0  1  2
0  1  2  3
1  4  5  6
2  7  8  9
</code></pre></div>
<p dir="auto">It feels like inconsistence.</p>
<p dir="auto">Hi there,</p>
<p dir="auto">I have a codebase that (so far) consumes data series in the form of dict-yielding iterators, similar in form to how DataFrame's constructor accepts a list of such. Unfortunately it seems from current implementation of that constructor, there is no straightforward way to consume from an iterator straight into a DataFrame.</p>
<p dir="auto">For example, I have a row factory for sqlite3 written in C that produces dicts. If pandas would accept an iterator, it should be possible to consume a series directly from speedy storage code into speedy data structure code. :)</p>
<p dir="auto">Is there an inherent limitation preventing this? Otherwise with a few pointers I would be willing to try contribute the patch myself.</p>
<p dir="auto">Thanks,</p>
<p dir="auto">David</p>