creating a pandas dataframe from a list first I create a dictionary then convert that to a dataframe
<p>I have a list that I have converted to a dictionary and want to convert the dictionary to a pandas dataframe.</p>

<p>My attempt is below however I am getting the following error:</p>

<blockquote>
  <p>'numpy.int64' object has no attribute 'DataFrame'</p>
</blockquote>

<pre><code>**df = pd.DataFrame.from_dict(a, orient='index')
</code></pre>

<p><strong>Sample of Data:</strong></p>

<pre><code>{'AAM': 2,
 'ABC': 5,
 'ABP': 3,
 'ABU': 1,
 'ACL': 3,
 'ACX': 6,
 'ADA': 7,
 'ADE': 2,
</code></pre>

<p>Here are the functions I have used to attempt to create the dataframe. The last line is causing the issue.</p>

<blockquote>
  <p>df = pd.DataFrame.from_dict(a, orient='index')</p>
</blockquote>

<pre><code>def list_to_dict(a_list):
    results = {}
    for i in a_list:
        i = str(i)
        if len(results.keys())==0: 
            results[i] = 1
        else:
            if i not in results.keys():
                results[i] = 1
            else:
                results[i] = results[i] + 1

    return results

flatten = df.mentions.tolist()
combined = [item for sublist in flatten for item in sublist]
a = list_to_dict(combined)
df = pd.DataFrame.from_dict(a, orient='index')
</code></pre>

<p>Do you just want the key and value as two columns or are you trying to do something else? If the former, this is all you need:</p>

<pre><code>pd.DataFrame(a.items())
</code></pre>

python pandas dataframe