Steve Hedden
Jun 2, 2021

--

Thanks for this suggestion Pedro. Yes, in this version I was just using the user IDs. If you want to add a new column for the username you can do this:

combined['username'] = combined['names'].apply(lambda x: getUserName(x))

Where the getUserName function is defined as:

def getUserName(x):

try:

u = api.get_user(x)

return u.screen_name

except:

return

Depending on the size of the df this may take some time as there are query limits.

--

--

Steve Hedden
Steve Hedden

Written by Steve Hedden

Product management, international development, data science and network analysis.

No responses yet