# Prepare JSON data from sentiment analysis to perform Logistic Regression

I'm new to this field, so very sorry for this basic question. I'm working on a text analysis project using Google's NLP API along with some other APIS. After performing the sentiment analysis I have its results in JSON format and now I need to apply the Logistic regression, I have no idea how can I prepare my JSON data to perform Logistic regress.

Here's a sample of my data:

{
'documentSentiment':{
'polarity':-0.3,
'magnitude':0,
'score':0
},
'language':'en',
'sentences':[
{
'text':{
'content':'{\\rtf1\\ansi\\ansicpg1252\\cocoartf1639\\cocoasubrtf100\n{\\fonttbl\\f0\\fswiss\\fcharset0 Helvetica;}\n{\\colortbl;\\red255\\green255\\blue255;}\n{\\*\\expandedcolortbl;;}\n\\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww10800\\viewh8400\\viewkind0\n\\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\\tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\pardirnatural\\partightenfactor0',
'beginOffset':-1
},
'sentiment':{
'polarity':-1,
'magnitude':0,
'score':0
}
},
{
'text':{
'content':'\\f0\\fs24 \\cf0 This is the first text file.}',
'beginOffset':-1
},
'sentiment':{
'polarity':1,
'magnitude':0,
'score':0
}
}
]
}


How can I prepare this data to perform Logistic Regression? I will use Pandas, Numpy and Sckikit-learn.

• You need to read about JSON a little bit.... Speaking frankly, it's just a kind of Dictionary, which has levels to it, So you need to extract the keys values, write it to A CSV file maybe or save it to a pamdas DataFrame! Nov 22, 2018 at 10:46
• Just index it like a normal list, keeping in mind that indices are strings here! From a top level view point Nov 22, 2018 at 10:52

Reputation barrier hence mentioning this as an answer, instead of a comment. This article should lead you the right way, as author has used Twitch API and Python to create his dataset. You shall get a feel of entire data flow.

EDIT: This is a nice tutorial on understanding (basically read/write) JSON files using Python.