I have a Dataframe containing some Ids, here for example the "manufacturers_id". Below a portion of my dataframe
With an api request, I am able to get the Manufacturer from the Id. My function looks like below:
def get_manufacturer(m_id):
url = "myapi/" + m_id + "?token=my_token"
response = requests.get(url)
manufacturer = json.loads(response.text)['name']
return manufacturer
Used individually, I can retrieve manufacturer from an Id.
But now, I want to apply this function to the whole column of my dataframe.
df['manufacturers_id'] = df['manufacturers_id'].apply(get_manufacturer(df['manufacturers_id']))
But It give me an error: str is not callable
. Or list indices must be integers or slices, not str
, depending on my tries
Any help would be appreciated.