【发布时间】:2018-03-15 06:15:00
【问题描述】:
我正在使用 twitter ID 在数据框中填充一些行。我第一次在没有 except 的情况下运行了脚本,但出现了错误:
[{'code': 144, 'message': 'No status found with that ID.'}]
我知道这可能是因为有人删除了推文或其他原因。但是,我需要继续前进!
所以我使用了except: pass,但它实际上并没有返回任何东西。所有行都是空的。我一直在努力解决这个问题,但我不知道如何解决它。
我的数据框:
TweetID text pageType
index
id1 My code is not working http://blablabla.com
id2 451864165416 Nan twitter
id3 849849849844 Nan twitter
这是不返回任何内容的代码:
try:
if (df['pageType'] == 'twitter').any:
df['text'] = df.tweetID.apply(lambda x: api.get_status(x).text)
except:
pass
就是这样! 非常感谢!
【问题讨论】:
标签: python pandas dataframe tweepy