I am working on the Page Visits Funnel project in R. Step 3 says"how long is the visits data frame?" I interpreted this to mean “how many rows”. When I coded that and hit save, nothing happened. So I checked the hint which says: " Use nrows() to find out the number of rows in a data frame." so I coded it this way:
total_visits <- visits %>%
nrows()
and also this way: total_visits <- nrows(visits)
Neither solution produces a result upon saving. What is the error, please?
Sorry, I also have a question about this project.
I´m trying to find the answer for step 5.
What percent of users who visited Cool T-Shirts Inc. ended up not placing a t-shirt in their cart?
I hope you can help me.
Thanks!
" Repeat the left join for cart and checkout and count NA values. What percentage of users put items in their cart, but did not proceed to checkout?"
So, before I could find the percentage mentioned, I needed to make a data frame which only had the carts that had not proceeded to checkout. To do this, I wrote the following code:
What percentage of users proceeded to checkout, but did not purchase a t-shirt?
I took a different approach to this question compared to the walkthrough video but I thought it makes sense until I realized the answer I got is different than the answer in the video. I got 0.147058823529, in the video the answer is 0.16889632107. Can anyone look through my code and let me know why did I get a different answer? I looked through the code a couple times and couldn’t figure out which part might have caused a different answer.
I approached the calculation based on the merged table of all four DataFrames but in the video, the solution is to only merge Checkout and Purchase dataframes and proceed with the calculations from there just like question 5 and 6.
Here is my code:
all_data = visits.merge(cart, how = 'left').merge(checkout, how = 'left').merge(purchase, how = 'left')
#Here I am trying to find how many users have reached to the checkout phase.
checkout = len(all_data[all_data.checkout_time.notnull()])
print(checkout)
#prints 816.
#Then, I find out how many people did not made a purchase but reached to the checkout phase by using logical operator '&' with notnull() and isnull().
purchase_null = len(all_data[all_data.checkout_time.notnull() & all_data.purchase_time.isnull()])
#prints 120.
print(float(purchase_null)/checkout)
#prints 0.147058823529
#4 Count NULL ( users who did not add to the cart )
cart_count = visits_cart[visits_cart.cart_time.isnull()]
print("Did not add to cart: "+ str(cart_count))
print(cart_count)
#5 Percentage of users who visted site, but did not add to cart
percent_visited = 100 * float(len(cart_count)) / len(visits)
print("Percent of users who visted site, but did not add to the cart : " + str(percent_visited) + “%”)
Can you post your formatted code so we can understand what you’re referring to? (also, it’s best to not revive old posts, but to search for previous answers first, then if you don’t find what you need to post your own topic, specific to your question). Also, the original question refers to R and not Python.