I am a hobby programmer and would like to solve a real-world problem I am having. I am a user of a software system that exposes an api that allows one to update/add records using Get. I have the imported the data I would like to modify the system with into Pandas and don't know the best way to iterate over the rows and dynamically create a URL.
I would like to create a URL for each row that is similar to:
below I have included the beginning of my code setup:
import pandas as pd
import requests as r
site = 'http://fakesite.org/servlet/Erp?'
payload = dict()
payload['_FORM'] = 'AD1'
payload['_EVT'] = 'ADD'
payload['_RTN'] = 'DATA'
payload['FC'] = 'Add'
payload['_OUT'] = 'XML'
payload['_EOT'] = 'TRUE'
data = {'F1': ['A','A','A'], 'F3': ['HELLO', 'GOODBYE', 'HELLO_AGAIN'], 'F16': ['EA','BX','CA']}
df = pd.DataFrame(data)
The "payload" dictionary I created is all the parameters that don't change for the request, these are essentially hard coded and not a part of the pandas data frame. I will ultimately combine this dictionary with the values in each row of the data frame before passing it to request.get
I think I need to use either use either apply or itterrows but I can't seem to figure it out.
How should I write this code?