Created
February 28, 2019 22:07
-
-
Save hamletbatista/2d7ab40fe4f31f5e62917fb3d5d5fadc to your computer and use it in GitHub Desktop.
Combine first
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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