<jupyter_start><jupyter_text>Fig 1<jupyter_code>df = pd.read_csv(
    "https://raw.githubusercontent.com/RDeconomist/observatory/main/Average%20real%20GDP%201910s%20%26%201920s.csv"
)
f = "fig1_twenties"
f1 = eco_git_path + f + ".csv"
df.to_csv("data/" + f + ".csv")
f += local_suffix
open("visualisation/" + f + ".html", "w").write(
    vega_embed.replace(
        "JSON_PATH", f1.replace("/data/", "/visualisation/").replace(".csv", ".json")
    )
)
if LOCAL:
    f1 = df
df.head()
bars = alt.Chart(f1).encode(
    x=alt.X(
        "Average real GDP:Q",
        stack=False,
        title="",
        axis=alt.Axis(
            grid=False,
            title="%",
            titleAnchor="end",
            titleX=415,
            titleY=7,
            labelColor=colors["eco-gray"],
            titleColor=colors["eco-gray"],
            tickColor=colors["eco-gray"],
            domainColor=colors["eco-gray"],
        ),
    ),
    y=alt.Y("Country:N", title="", axis=None),
)

bars1 = (
    bars.mark_bar(size=11, yOffset=-10, color=colors["eco-turquiose"], opacity=0.8)
    .transform_filter("datum.Decade=='1910s average'")
    .transform_filter("datum['Average real GDP']>0")
)
labels1 = (
    bars1.mark_text(align="left", xOffset=5, yOffset=-10, color=colors["eco-turquiose"])
    .encode(text="label:N")
    .transform_calculate(label="'+'+round(datum['Average real GDP']*10)/10")
)
bars2 = (
    bars.mark_bar(size=11, yOffset=-10, color=colors["eco-pink"], opacity=0.8)
    .transform_filter("datum.Decade=='1910s average'")
    .transform_filter("datum['Average real GDP']<=0")
)
labels2 = (
    bars2.mark_text(align="right", xOffset=-5, yOffset=-10, color=colors["eco-pink"])
    .encode(text="label:N")
    .transform_calculate(label="round(datum['Average real GDP']*10)/10")
)
labels2b = (
    bars2.mark_text(align="right", xOffset=-3, yOffset=-10, color="#ffffff")
    .encode(text="label:N", x="x:Q")
    .transform_calculate(x="0")
    .transform_calculate(label="'1910s'")
)
bars3 = (
    bars.mark_bar(size=11, yOffset=2, color=colors["eco-light-blue"], opacity=0.8)
    .transform_filter("datum.Decade=='1920s average'")
    .transform_filter("datum['Average real GDP']>0")
)
labels3 = (
    bars3.mark_text(align="left", xOffset=5, yOffset=4, color=colors["eco-light-blue"])
    .encode(text="label:N")
    .transform_calculate(label="'+'+round(datum['Average real GDP']*10)/10")
)
labels1b = (
    bars1.mark_text(align="left", xOffset=3, yOffset=-10, size=10, color="#ffffff")
    .encode(text="label:N", x="x:Q")
    .transform_calculate(x="0")
    .transform_calculate(label="'1910s'")
    .transform_filter("datum['Average real GDP']>1")
)
labels3b = (
    bars3.mark_text(align="left", xOffset=3, yOffset=3, size=10, color="#ffffff")
    .encode(text="label:N", x="x:Q")
    .transform_calculate(x="0")
    .transform_calculate(label="'1920s'")
    .transform_filter("datum['Average real GDP']>1")
    .transform_filter("datum['Average real GDP']<5")
)
labels3b2 = (
    bars3.mark_text(align="left", xOffset=3, yOffset=3, size=10, color="#ffffff")
    .encode(text="label:N", x="x:Q")
    .transform_calculate(x="0")
    .transform_calculate(label="'1920s average'")
    .transform_filter("datum['Average real GDP']>5")
)
labels = (
    bars.mark_text(align="right", xOffset=-5, yOffset=4, color=colors["eco-gray"])
    .encode(text="Country:N", x="x:Q")
    .transform_calculate(x="0")
)
rule = (
    alt.Chart(pd.DataFrame([{"x": 0}]))
    .mark_rule(color=colors["eco-gray"])
    .encode(x="x:Q")
)

layers = (
    (
        bars1
        + labels1
        + bars2
        + labels2
        + bars3
        + labels3
        + rule
        + labels
        + labels2b
        + labels1b
        + labels3b
        + labels3b2
    )
    .configure_view(stroke=None)
    .properties(title="")
    .properties(height=300, width=400)
)

layers.save("visualisation/" + f + ".json")
layers<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1980248164092175, 'fraction_numerical': 0.0407698151430742, 'mean_word_length': 3.5983701979045404, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '285456', 'license': 'MIT', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1464, 'n_words': 193, 'path': 'articles/2021-06-08-are-we-about-to-experience-another-roaring-twenties/parser.ipynb', 'repo_name': 'MW17668/ECOvisualisations', 'size': '3949'}