title: Using pandas to read JSON file for Python analysis
body: <p>I'm running into some issues, trying to load a JSON file in my Python editor so that I can run some analysis on the data within.</p>
  
  <p>The JSON file is in the following folder: <code>'C:\Users\Admin\JSON files\file1.JSON'</code></p>
  
  <p>It contains the following tweet data (this is just one record, there are hundreds in there):</p>
  
  <pre><code>{
      "created": "Fri Mar 13 18:09:33 GMT 2014",
      "description": "Tweeting the latest Playstation news!",
      "favourites_count": 4514,
      "followers": 235,
      "following": 1345,
      "geo_lat": null,
      "geo_long": null,
      "hashtags": "",
      "id": 2144411414,
      "is_retweet": false,
      "is_truncated": false,
      "lang": "en",
      "location": "",
      "media_urls": "",
      "mentions": "",
      "name": "Playstation News",
      "original_text": null,
      "reply_status_id": 0,
      "reply_user_id": 0,
      "retweet_count": 4514,
      "retweet_id": 0,
      "score": 0.0,
      "screen_name": "SevenPS4",
      "source": "&lt;a href=\"http://twitterfeed.com\" rel=\"nofollow\"&gt;twitterfeed&lt;/a&gt;",
      "text": "tweetinfohere",
      "timezone": "Amsterdam",
      "url": null,
      "urls": "http://bit.ly/1lcbBW6",
      "user_created": "2013-05-19",
      "user_id": 13313,
      "utc_offset": 3600
  }
  </code></pre>
  
  <p>I am using the following code to try and test this data:</p>
  
  <pre><code>import json
  import pandas as pa
  z = pa.read_json('C:\Users\Admin\JSON files\file1.JSON')
  d = pa.DataFrame.from_dict([{k:v} for k,v in z.iteritems() if k in ["retweet_count", "user_id", "is_retweet"]])
  print d.retweet_count.sum()
  </code></pre>
  
  <p>When I run this, it successfully reads the JSON file then prints out a list of the retweet_count's like this:</p>
  
  <p><code>0, 4514
  1, 300
  2, 450
  3, 139</code> etc etc</p>
  
  <p>My questions:
  How do I actually sum up all of the retweet_count/user_id values rather than just listing them like shown above?</p>
  
  <p>How do I then divide this sum by the number of entries to get an average?</p>
  
  <p>How can I choose a sample size of the JSON data rather than use it all? (I thought it was d.iloc[:10] but that doesn't work)</p>
  
  <p>With the 'is_retweet' field in the JSON file, is it possible to make a count for the amount of false/trues that are given? IE within the JSON file, I want the number of tweets that were retweeted and the number that weren't.</p>
  
  <p>Thanks in advance, yeah I'm pretty new to this..</p>
  
  <p><code>z.info()</code> gives:</p>
  
  <p><code>&lt;class 'pandas.core.frame.DataFrame'&gt;
  Int64Index: 506 entries, 0 to 505
  Data columns (total 31 columns):
  created             506 non-null object
  description         506 non-null object
  favourites_count    506 non-null int64
  followers           506 non-null int64
  following           506 non-null int64
  geo_lat             10 non-null float64
  geo_long            10 non-null float64
  hashtags            506 non-null object
  id                  506 non-null int64
  is_retweet          506 non-null bool
  is_truncated        506 non-null bool
  lang                506 non-null object
  location            506 non-null object
  media_urls          506 non-null object
  mentions            506 non-null object
  name                506 non-null object
  original_text       172 non-null object
  reply_status_id     506 non-null int64
  reply_user_id       506 non-null int64
  retweet_id          506 non-null int64
  retweet_count       506 non_null int64
  score               506 non-null int64
  screen_name         506 non-null object
  source              506 non-null object
  status_count        506 non-null int64
  text                506 non-null object
  timezone            415 non-null object
  url                 273 non-null object
  urls                506 non-null object
  user_created        506 non-null object
  user_id             506 non-null int64
  utc_offset          506 non-null int64
  dtypes: bool(2), float64(2), int64(11), object(16)</code></p>
  
  <p>How come it is showing retweet_count and user_id as objects when I run d.info()?</p>