Logo

dev-resources.site

for different kinds of informations.

Website Time dataset

Published at
9/1/2024
Categories
python
kaggle
datascience
Author
victordalet
Categories
3 categories in total
python
open
kaggle
open
datascience
open
Author
11 person written this
victordalet
open
Website Time dataset

Hello, I found a dataset on kaggle in the time of use of a website, so I want to find a ratio between the number of pages visited and the total time in the website.

You can find the dataset and the code in my github : https://github.com/victordalet/Kaggle_analysis/tree/feat/website_traffic


I - Installation

To do this, I use sqlalchemy in python to convert my csv into a database and plotly to display my results.

pip install plotly
pip install sqlalchemy
Enter fullscreen mode Exit fullscreen mode

II - Code

I create a Main class, in which I retrieve my csv and put it in a database, using the get_data method.
The result is a list of tuples, so I create the transform_data method to obtain a double list.
Finally, I can display a simple graph between the number of pages viewed and the total time.

import pandas as pd
from sqlalchemy import create_engine, text
import plotly.express as px


class Main:
    def __init__(self):
        self.result = None
        self.connection = None

        self.engine = create_engine("sqlite:///my_database.db", echo=False)
        self.df = pd.read_csv("website_wata.csv")
        self.df.to_sql("website_data", self.engine, index=False, if_exists="append")
        self.get_data()
        self.transform_data()
        self.display_graph()


    def get_data(self):
        self.connection = self.engine.connect()
        query = text("SELECT Page_Views, Time_on_Page FROM website_data")
        self.result = self.connection.execute(query).fetchall()

    def transform_data(self):
        for i in range(len(self.result)):
            self.result[i] = list(self.result[i])


    def display_graph(self):
        fig = px.scatter(
            self.result, x=0, y=1, title=""
        )
        fig.show()


Main()
Enter fullscreen mode Exit fullscreen mode

III - Result

The x-axis indicates the number of pages visited by the user, while the y-axis shows the time spent on the website in minutes.

We can see that the users who stay the longest visit between 4 and 6 pages, and that between 11 and 15 pages all users stay at least a few minutes.

Image description

kaggle Article's
30 articles in total
Favicon
Building My First ML Model Using Amazon SageMaker + Kaggle + Jupyter Notebook
Favicon
15+ Useful PYTHON Libraries for Data Science
Favicon
Top 10 SQL projects with Kaggle Datasets
Favicon
Flux Dev - ComfyUI 1-CLICK Kaggle Notebook
Favicon
Stable Diffusion 3.5 Large (FP16) - ComfyUI 1-CLICK Kaggle Notebook
Favicon
How to setup the Nvidia TAO Toolkit on Kaggle Notebook
Favicon
Passing Input Arguments in Kaggle Notebook Using Environment Variables
Favicon
Style Your Kaggle Notebook
Favicon
Website Time dataset
Favicon
Create chat bot - JO PARIS 2024
Favicon
Partnership between Dev Community and Kaggle to help writers with their notebooks?
Favicon
Amazon product dataset
Favicon
Technical Report: Initial Data Analysis of Titanic Datasets
Favicon
Leveraging Kaggle for Free Geographical Data: A Guide to Integrating with PostGIS via QGIS
Favicon
πŸ“’ Neo4J Ninjas as Kaggle dataset πŸ₯·
Favicon
Google Gemma first try
Favicon
Tutorial: Creating Dataset The Elder Scroll: Skyrim Armor and Sending to Kaggle Datasets
Favicon
How To Do Stable Diffusion XL (SDXL) DreamBooth Training For Free - Utilizing Kaggle - Easy Tutorial
Favicon
Now you can do full Stable Diffusion XL (SDXL) DreamBooth training on Kaggle for free under 2 hours.
Favicon
How To Do Stable Diffusion XL (SDXL) Full DreamBooth Fine Tuning Training For Free via Kaggle
Favicon
How To Do Stable Diffusion XL (SDXL) LoRA Training For Free On Cloud (Kaggle)
Favicon
Kaggle Coleridge 52nd Solution
Favicon
How to use Kaggle for Climate Change studies
Favicon
Kaggle SETI 59th Solution
Favicon
5 Tools to Start Working with Python 🀯☒️😱
Favicon
πŸ¦† From API to scheduled offline copies with DuckDB on Kaggle ♾️
Favicon
SageMaker Data Ingestion using Kaggle
Favicon
Kaggle's Intro to Programming: A Short Review
Favicon
Tweets from heads of governments and states
Favicon
4 Tools Kaggle Grandmasters use to win $100,000s in competitions

Featured ones: