Skip to content

Instantly share code, notes, and snippets.

View andreluizjaques's full-sized avatar

André Luiz Jaques Alves andreluizjaques

View GitHub Profile
@andreluizjaques
andreluizjaques / SQL StrataScratch
Last active June 6, 2022 23:59
Users By Average Session Time
/*
Users By Average Session Time
Difficulty: Medium
Calculate each user's average session time. A session is defined as the time difference between a page_load and page_exit.
For simplicity, assume a user has only 1 session per day and if there are multiple of the same events on that day,
consider only the latest page_load and earliest page_exit. Output the user_id and their average session time.
Table:
#importando as bibliotecas
import pandas as pd
import json
import requests, json
#realizando uma requisição atráves da api com os dados
url = requests.get("https://cotacao.b3.com.br/mds/api/v1/DerivativeQuotation/DI1")
#lendo o conteúdo da resposta
text = url.text