having the following code below. Scenario description:
Iterate over the dataframe having the list of URLs Send GET request. Create initially 3 new columns and update them based on the results from the previous get request.
Question: Is there any option how to do write the 3 "df.set_value" in one line of code??
Many thanks in advance
import pandas as pd, numpy as np
d = {'ListOfURLs': ['URL1', 'URL2', 'URL3']}
df = pd.DataFrame(data=d)
#print(df)
s = requests.session()
s.post(login_url, login_data)
for index, row in df.iterrows():
r = s.get(row['ListOfURLs'])
r.status_code
if r.status_code == 200:
# Update Dataframe , create initially 3 new columns and update them based on the results from the previous get request
df.set_value(index, 'Status Code', r.status_code)
df.set_value(index, 'Result', '[OK]')
df.set_value(index, 'Error', np.nan)