Public
Edited
Dec 16, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
median_ratio_scaler(3.3012)
Insert cell
d3.extent(regional_dailies, d => d.median_ratio)
Insert cell
median_ratio_scaler.domain()
Insert cell
median_ratio_scaler =
d3.scaleLog([0, 1])
// .domain(d3.extent(regional_dailies, d => d.median_ratio))
.domain([0.0625, d3.max(regional_dailies, d => d.median_ratio)])
.base(2) // TODO: Add clamp left al range para que no se vaya negativo
Insert cell
Plot.plot({
height: 500,
marginRight: 100,
x: {
'type': 'log',
base: 2,
domain: d3.extent(regional_dailies, d => d.median_ratio),
},
marks: [
// Plot.axisX({type: 'log'}),
Plot.rectY(regional_dailies, Plot.binX({y: "count"}, {x: "median_ratio", fy: 'region_name', tip:true})),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
regional_dailies
select region_name,
median(clientes_afectados) as day_median,
mean(clientes_afectados) as day_mean,
from regional_dailies
group by region_name
Insert cell
datadb
with initial_table as (
select
strftime("timestamp", '%Y-%m-%d')::DATE as timestamp_date,
region_name,
max(totalClientsWithoutService) as clientes_afectados,
from regionsWithoutService
where "type" = 'region'
group by timestamp_date, region_name
)

select *,
median(clientes_afectados) over (partition by (region_name)) as day_median,
clientes_afectados / day_median as median_ratio
from initial_table
order by timestamp_date, region_name

Insert cell
Insert cell
datadb
select *
from regionsWithoutService
Insert cell
Insert cell
<style>
@import url('https://fonts.googleapis.com/css2?family=B612+Mono&display=swap');
</style>
Insert cell
import {m4} from "@uwdata/m4-scalable-time-series-visualization"
Insert cell
import {datadb} from "3bd1064313a4d2c3"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more