'Extracting data from a namedtuple received from Twitter API v2
I extracted a list of 10 twitter followers as follows:
list_of_followers = api.get_users_followers(get_followers_of, max_results=10)
list_of_followers
This resulted in the following namedtuple (ids, names, etc. are fictional):
Response(data=[<User id=12 name=meh_em username=NightC>, <User id=14 name=TheCryz username=thecryz>, <User id=70 name=addict username=addict>, <User id=27 name=smth username=smth>, <User id=135 name=camer00n username=camer00n>, <User id=1477 name=Artsyb username=artsyb_5>, <User id=8268 name=dfmlsadfn username=dfmlsadfn>, <User id=25627 name=blooodb username=blooodb>, <User id=147747 name=188151653 username=188151653n>, <User id=1485205 name=Roarrrrr username=Roarrrrr>], includes={}, errors=[], meta={'result_count': 10, 'next_token': 'QDEH6VKCAJLHEZZZ'})
I cannot find a way to format the returned data into pandas df. I would like to have 3 columns with User id, name, and username. Any suggestions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
