<p dir="auto"><code class="notranslate">Generator</code> inherits from <code class="notranslate">Iterator</code>, <code class="notranslate">Iterator</code> inherits from <code class="notranslate">Iterable</code>. And <code class="notranslate">list([iterable])</code> takes an <code class="notranslate">Iterable</code> as argument.</p>
<p dir="auto">So, why <code class="notranslate">data</code> in <code class="notranslate">DataFrame(data)</code> can't be an <code class="notranslate">Iterable</code>?</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/pandas-dev/pandas/blob/620abc403d371446afe38fc1e63f0d90ea27b80a/pandas/core/frame.py#L381-L383">pandas/pandas/core/frame.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 381 to 383
      in
      <a data-pjax="true" class="commit-tease-sha" href="/pandas-dev/pandas/commit/620abc403d371446afe38fc1e63f0d90ea27b80a">620abc4</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L381" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="381"></td>
          <td id="LC381" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">elif</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">data</span>, (<span class="pl-s1">list</span>, <span class="pl-s1">types</span>.<span class="pl-v">GeneratorType</span>)): </td>
        </tr>

        <tr class="border-0">
          <td id="L382" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="382"></td>
          <td id="LC382" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">data</span>, <span class="pl-s1">types</span>.<span class="pl-v">GeneratorType</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L383" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="383"></td>
          <td id="LC383" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-en">list</span>(<span class="pl-s1">data</span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<br>
<div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/pandas-dev/pandas/blob/620abc403d371446afe38fc1e63f0d90ea27b80a/pandas/core/frame.py#L407-L408">pandas/pandas/core/frame.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 407 to 408
      in
      <a data-pjax="true" class="commit-tease-sha" href="/pandas-dev/pandas/commit/620abc403d371446afe38fc1e63f0d90ea27b80a">620abc4</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L407" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="407"></td>
          <td id="LC407" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">elif</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">data</span>, <span class="pl-s1">collections</span>.<span class="pl-v">Iterator</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L408" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="408"></td>
          <td id="LC408" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">raise</span> <span class="pl-v">TypeError</span>(<span class="pl-s">"data argument can't be an iterator"</span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></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>