“I have a dataframe called products and one columns has the url that I'm trying to splits.
ID URL
101015 https://defrost/kskswn_sourcefsr_3rt=forst23=rt5s_campaign10=new_york65007
"
I'm trying to see if it is possible to split the url in multiple part in order to understand where people click on the link and which campaign they click
The goal is to have anything between the equal sign '=' in its own columns
I try this code and a bunch of others
def parse_url(files_1):
for index, row in files_1.iterrows():
parsed = urlparse(str(row)).query
parsed = parse_qs(parsed)
for k, v in parsed.items():
df.loc[index, k.strip()] = v[0].strip().lower()
return files_1
parse_url(files_2['CLICK_URL'])
The goal is to have something like this:
ID COL1 COL2 COL3
101015 https://defrost/kskswn_sourcefsr_campaign_3rt rt5s_campaign10 new_york65007