convert dataframe column of type 'object' into type list
<p>Trying to convert the <code>object</code> type column of a <code>dataframe</code> into a list of <code>dicts</code> as it actually needs to be.</p>

<pre><code>print df['A'].dtype
object

print df['A'][:1]
[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]
</code></pre>

<p>Is it possible to retrieve <code>df['A']</code> as a list of <code>dicts</code> as <code>dicts</code>? Any help highly appreciated. </p>

<p>use <code>json</code></p>

<pre><code>import json

df.A.apply(json.loads)

0    [{u'c': 47, u'at': u'con'}, {u'z': 47, u'at': ...
1    [{u'c': 47, u'at': u'con'}, {u'z': 47, u'at': ...
2    [{u'c': 47, u'at': u'con'}, {u'z': 47, u'at': ...
3    [{u'c': 47, u'at': u'con'}, {u'z': 47, u'at': ...
4    [{u'c': 47, u'at': u'con'}, {u'z': 47, u'at': ...
5    [{u'c': 47, u'at': u'con'}, {u'z': 47, u'at': ...
Name: A, dtype: object
</code></pre>

<h3>Setup</h3>

<pre><code>df = pd.DataFrame([
        '[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]',
        '[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]',
        '[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]',
        '[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]',
        '[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]',
        '[{"at": "con", "c": 47}, {"at": "cli", "z": 47}, {"at": "cks", "d": 5}]',
    ],
    columns=['A'])
</code></pre>

python pandas dataframe