I have this dataset.
{
"date": "2018-01-01",
"body": "some txt",
"id": 111,
"sentiment": null
},
{
"date": "2018-01-02",
"body": "some txt",
"id": 112,
"sentiment": {
"basic": "Bearish"
}
}
I want to read this with pandas, and change the column sentiment foreach rows differents from null.
When I do this:
pd.read_json(path)
this is the result that I get:
body ... sentiment
0 None
1 {u'basic': u'Bullish'}
I don't want to have {u'basic': u'Bullish'} but only the value of basic.
So to find the correct rows I use
df.loc[self.df['sentiment'].isnull() != True, 'sentiment'] = (?)
and it work, but I don't know what I have to put instead of (?)
I've tried this but doens't work
df.loc[self.df['sentiment'].isnull() != True, 'sentiment'] = df['sentiment']['basic]
Any ideas? Thanks