Platform
Resources
Pricing
Sign in
Get started
Javier Cardenas
Workspace
Fork
Public
By
Javier Cardenas
Edited
Jan 14, 2024
Fork of
Consumer Price Index - Change from a year ealier
1
Insert cell
Insert cell
cpi.csv
Filter
Columns
Sort
Slice
Save
Type Table, then Shift-Enter. Ctrl-space for more options.
Insert cell
import
{
aq
,
op
}
from
'@uwdata/arquero'
Insert cell
cpi
.
forEach
(
(
d
,
i
)
=>
{
d
.
aucslChange
=
0
d
.
lfeslChange
=
0
if
(
i
>=
12
)
{
d
.
aucslChange
=
(
d
.
CPIAUCSL
-
cpi
[
i
-
12
]
.
CPIAUCSL
)
/
cpi
[
i
-
12
]
.
CPIAUCSL
d
.
lfeslChange
=
(
d
.
CPILFESL
-
cpi
[
i
-
12
]
.
CPILFESL
)
/
cpi
[
i
-
12
]
.
CPILFESL
}
}
)
Insert cell
cpi
Insert cell
cpiData
=
cpi
.
filter
(
d
=>
(
d
.
observation_date
.
getUTCFullYear
(
)
>
2014
)
)
Insert cell
cpidf
=
aq
.
from
(
cpiData
)
.
view
(
)
Insert cell
Plot
.
plot
(
{
height
:
423
,
width
:
650
,
y
:
{
grid
:
true
,
ticks
:
6
,
domain
:
[
-
0.02
,
0.1
]
,
tickFormat
:
"%"
}
,
marks
:
[
Plot
.
axisX
(
{
label
:
null
,
tickFormat
:
(
d
)
=>
{
const
year
=
d
.
getUTCFullYear
(
)
;
if
(
year
===
2015
)
{
return
year
;
}
if
(
year
===
2020
)
{
return
"'20"
;
}
}
}
)
,
Plot
.
ruleY
(
[
0
]
)
,
Plot
.
line
(
cpiData
,
{
x
:
"observation_date"
,
y
:
"lfeslChange"
,
stroke
:
"#bb2b77"
,
strokeWidth
:
2
,
strokeLinecap
:
"square"
,
strokeLinejoin
:
"bevel"
}
)
,
Plot
.
line
(
cpiData
,
{
x
:
"observation_date"
,
y
:
"aucslChange"
,
stroke
:
"#323232"
,
strokeWidth
:
2
,
strokeLinecap
:
"round"
,
strokeDasharray
:
"0.1 5"
}
)
]
}
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cpi
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
File attachments
cpi.csv
CSV
Databases
Filter
Column
Operator
Columns
Sort
Column
Direction
Descending
Ascending
Slice
From
Start
To
End
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cpiData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cpidf
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML