Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Combine first
# We do a left merge to append the redirect information to our original GA dataframe.
data_redirects = data.merge(redirects, left_on="url", right_on="url", how="left")
data_redirects['true_url'] = data_redirects['redirect_url'].combine_first(data_redirects['path'])
data_redirects['true_url'] = data_redirects['true_url'].apply(lambda x: urlparse(x).path)
data_redirects['ga:date'] = pd.to_datetime(data_redirects['ga:date'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.