1

I have a df that looks like this:

id          tags
1           [independent_press,ball]

I am using this API call to update a contact with a particular tag. However I want to push in all the tags into the contact.

The documentation says I can pass in multiple comma separated tags.How do I do this with the list in the tags column? The code needs to also be flexible because sometimes there will be only one value in the tags column not in a list like below and other times there will be multiple values in a list but always in a list format as above.

id          tags
1            a

this is my API call so far with the df:

    for index, row in df.iterrows():
        params = {
            'id': row['id'],
            'p[20]*': 20,
            'status[123]':1,
            'tags':row['tags'],
            }
        resp = r.post(url, data=params, headers=headers)
        print(resp)
        print(resp.text)
RustyShackleford
  • 3,462
  • 9
  • 40
  • 81

1 Answers1

1

try it with F-Strings, its very handy. (Python 3.6+) like:

id = row["id"]
anyvalue = "anyvalue"
params = f"id={id},nextvalue={anyvalue}"
cs95
  • 379,657
  • 97
  • 704
  • 746
DevSepp
  • 116
  • 1
  • 5