tweepy json获取AttributeError:'int'对象没有属性'items'

时间:2017-05-13 04:47:53

标签: json pandas tweepy

我按照http://adilmoujahid.com/posts/2014/07/twitter-analytics/

的代码收集了大约12,000条推文

问题是,一旦推文数量增加,我就会收到错误。较小的数字不会产生这个问题。

#adding columns
from pandas.io.json import json_normalize    
tweets = json_normalize(tweet_data)[["text", "lang", "created_at", "user.time_zone", "user.location"]]

这给了我这样的结果

AttributeError                            Traceback (most recent call last)
<ipython-input-21-19596361d3f0> in <module>()
      1 #adding columns
      2 from pandas.io.json import json_normalize
----> 3 tweets = json_normalize(tweet_data)[["text", "lang", "created_at", "user.time_zone",                                     "user.location"]]

/usr/lib/python2.7/dist-packages/pandas/io/json.pyc in json_normalize(data, record_path, meta, meta_prefix, record_prefix)
    713             # TODO: handle record value which are lists, at least error
    714             #       reasonably
--> 715             data = nested_to_record(data)
    716         return DataFrame(data)
    717     elif not isinstance(record_path, list):

/usr/lib/python2.7/dist-packages/pandas/io/json.pyc in nested_to_record(ds, prefix, level)
    612 
    613         new_d = copy.deepcopy(d)
--> 614         for k, v in d.items():
    615             # each key gets renamed with prefix
    616             if level == 0:

AttributeError: 'int' object has no attribute 'items'

有没有办法摆脱这种情况我完全是处理Pandas和Json的新手。

0 个答案:

没有答案