Pandas pd.DataFrame converts to Tuples instead of Dataframe
<p>I first use BeautifulSoup:</p>

<pre><code>mydivs = soup.findAll('div', {"class": "content"})
</code></pre>

<p>so that each <code>mydiv</code> in <code>mydivs</code> looks like this for example:</p>

<pre><code>&lt;div class="content"&gt;A number of hats by me &lt;br/&gt;&lt;br/&gt;three now though ... &lt;/div&gt;
</code></pre>

<p>I then want to store each of the text blocks in each <code>div</code> as rows in a dataframe. I want the dataframe to look something like:</p>

<pre><code>index posts
0     &lt;div class="content"&gt;A number of  &lt;br/&gt;&lt;br/&gt;three  ... &lt;/div&gt;
1     &lt;div class="content"&gt;Stack ... &lt;br/&gt;&lt;br/&gt;overflow  ... &lt;/div&gt;
...
</code></pre>

<p>This is the code I tried</p>

<pre><code>A=[]
indices=[]
j=0

for div in mydivs:
    A.append(div)
    indices.append(j)
    j+=1

DF = pd.DataFrame({'index': indices, "posts": A})
</code></pre>

<p>When I then print out the <code>shape</code> I get</p>

<pre><code>print DF.shape()
TypeError: 'tuple' object is not callable
</code></pre>

<p>However, I want <code>DF</code> to be a dataframe, not a <code>tuple</code>. How can I fix this?</p>

<p>shape is an attribute of <code>DF</code>. That attribute is a <code>tuple</code>. You are trying to call it with the <code>()</code> which is throwing the error. If you want the shape just do <code>DF.shape</code></p>

<pre><code>print DF.shape
</code></pre>

<p><strong><em>not</em></strong></p>

<pre><code>print DF.shape()
</code></pre>

python pandas dataframe