I have a CSV that has a list of URLs that I need to see if they exist in other columns. I have the following code that loops through each row of the column called "URLS" that checks to see if this exists on another specific column. If this does, then I need to add a string to a specific column for the row. I have it functioning, but I'm not sure how I update the column for the row? I'm reading through the docs and I'm thinking I might be over thinking a bit on this.
import pandas as pd
# Import CSV
data = pd.read_csv(r'URL_export.csv')
# Looping through the URLS of this column
df = pd.DataFrame(data, columns = ['URL', 'Exists'])
# Checking if URLs exist in this row
v = pd.DataFrame(data, columns = ['Check'])
for row in df.itertuples():
if row.URL in v.Check.values:
print(row)
# Add string "Yes" under column name "Exists" for this row

Pandas(Index=11, URL='name_of_url_page.html', Check=nan). For each of these, I'd like to change the data inside the "Check" column, but I'm not entirely sure what method I'd go about doing this?df['URL'].isin(v['CheckLight'])?if row.URL in v.Check.values:instead ofif row.URL in v.CheckLight.values:. I adjusted that, and tried what you posted but it didn't do anything it seemed. I checked the documentation and it looks like it might work, I might need to refactor my code a bit. I'll work with it and see what I can come up with.df.loc[[row.Index], ["Exists"]] = "Yes"in my if statement but it's not updating the column for these rows either. However, when I printdf.loc[[row.Index]], it returns the index and columns, which makes me think this should be working according to the documentation. link