I am trying to access data from a JSON file into a pandas dataframe and seem to be stuck on how to retrieve a data within a map of the JSON.
I want to retrieve the followers_count entity within the user object of this json into a dataframe.
JSON File (sample record) below:
{"created_at": "Tue Aug 01 16:23:56 +0000 2017", "id": 892420643555336193, "retweet_count": 12345, "favorite_count": 23456, "user": {"id": 4196983835, "followers_count": 3200889, "friends_count": 104}}
here is what I have in terms of code (doesnt work as I dont know how to fetch the followers_count within the user object :
tweet_data_df = pd.read_json('tweet-json.txt', lines=True)
#Doesnt work
#tweet_data_df = tweet_data_df[['id', 'favorite_count', 'retweet_count', 'created_at', 'user''followers_count']]
#works but not enough for me
tweet_data_df = tweet_data_df[['id', 'favorite_count', 'retweet_count', 'created_at']]
tweet_data_df.head(5)
Appreciate your help !