Skip to content Skip to sidebar Skip to footer

Parsing Json Files

Below is the code for visual analysis of a set of tweets obtained in a .json file. Upon interpreting , an error is shown at the map() function. Any way to fix it? import json impor

Solution 1:

I think you can use read_json:

import pandas as pd

df = pd.read_json('file.json')
print df.head()
                       contributors  coordinates          created_at entities  \
contributors_enabled            NaN          NaN 2016-03-05 05:47:23      NaN   
created_at                      NaN          NaN 2016-03-05 05:47:23      NaN   
default_profile                 NaN          NaN 2016-03-05 05:47:23      NaN   
default_profile_image           NaN          NaN 2016-03-05 05:47:23      NaN   
description                     NaN          NaN 2016-03-05 05:47:23      NaN   

                       favorite_count favorited filter_level  geo  \
contributors_enabled                0     False          low  NaN   
created_at                          0     False          low  NaN   
default_profile                     0     False          low  NaN   
default_profile_image               0     False          low  NaN   
description                         0     False          low  NaN   

                                       id              id_str  \
contributors_enabled   705993088574033920  705993088574033920   
created_at             705993088574033920  705993088574033920   
default_profile        705993088574033920  705993088574033920   
default_profile_image  705993088574033920  705993088574033920   
description            705993088574033920  705993088574033920   

                                    ...                is_quote_status  lang  \
contributors_enabled                ...                          False    en   
created_at                          ...                          False    en   
default_profile                     ...                          False    en   
default_profile_image               ...                          False    en   
description                         ...                          False    en   

                       place  retweet_count  retweeted  \
contributors_enabled     NaN              0      False   
created_at               NaN              0      False   
default_profile          NaN              0      False   
default_profile_image    NaN              0      False   
description              NaN              0      False   

                                                                  source  \
contributors_enabled   <a href="http://javascriptiseasy.com" http://javascriptiseasy.com" http://javascriptiseasy.com" http://javascriptiseasy.com" http://javascriptiseasy.com" rel="nof...   

                                                                    text  \
contributors_enabled   Tumi Inc. civil war: Staff manning US ceasefir...   
created_at             Tumi Inc. civil war: Staff manning US ceasefir...   
default_profile        Tumi Inc. civil war: Staff manning US ceasefir...   
default_profile_image  Tumi Inc. civil war: Staff manning US ceasefir...   
description            Tumi Inc. civil war: Staff manning US ceasefir...   

                                 timestamp_ms  truncated  \
contributors_enabled  2016-03-05 05:47:23.690      False   
created_at            2016-03-05 05:47:23.690      False   
default_profile       2016-03-05 05:47:23.690      False   
default_profile_image 2016-03-05 05:47:23.690      False   
description           2016-03-05 05:47:23.690      False   

                                                 user  
contributors_enabled                            False  
created_at             Sat Dec 05 11:18:00 +0000 2015  
default_profile                                 False  
default_profile_image                           False  
description                             Get learning!  

[5 rows x 25 columns]

Post a Comment for "Parsing Json Files"