-
-
Save codecademydev/fd31e9269f4d1eebbb9014e6e73fd9be to your computer and use it in GitHub Desktop.
Codecademy export
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
import codecademylib | |
import pandas as pd | |
visits = pd.read_csv('visits.csv', | |
parse_dates=[1]) | |
cart = pd.read_csv('cart.csv', | |
parse_dates=[1]) | |
checkout = pd.read_csv('checkout.csv', | |
parse_dates=[1]) | |
purchase = pd.read_csv('purchase.csv', | |
parse_dates=[1]) | |
#ppl visit + cart or not | |
visit_to_cart = pd.merge(visits, cart, how = 'left') | |
num_visit = len(visit_to_cart) | |
print(num_visit) | |
#num of ppl visiting :2052 | |
visit_to_cart['no_cart'] = ~ visit_to_cart.cart_time.isnull() | |
num_no_cart = visit_to_cart.no_cart.sum() | |
print(num_no_cart) | |
#num of ppl no_cart:1652 | |
percent_visit_no_cart = float(num_no_cart)/num_visit | |
print(percent_visit_no_cart) | |
#0.805068226121 | |
cart_to_checkout = cart.merge(checkout, how = 'left') | |
num_cart = len(cart_to_checkout) | |
print(num_cart) | |
#num of people cart :602 (some people put it in the cart without visiting first???) | |
no_checkout = cart_to_checkout[cart_to_checkout.checkout_time.isnull()] | |
num_no_checkout = len(no_checkout) | |
print(num_no_checkout) | |
#num of ppl no_checkout :126 | |
percent_cart_no_checkout = float(num_no_checkout)/num_cart | |
print(percent_cart_no_checkout) | |
#0.209302325581 | |
all_data = visits.merge(cart, how = 'left').merge(checkout, how = 'left').merge(purchase, how = 'left') | |
print(len(visits)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment