<commit_before>#! /usr/bin/env streamlit run

from pathlib import Path
import datetime as dt

import altair as alt
import pandas as pd
import streamlit as st


def _now():
    return dt.datetime.now().replace(microsecond=0)


def _get_nyt_covid19_top_dir():
    repo_top = Path(__file__ + '/../../..').resolve()
    sibling_repo = repo_top / '../covid-19-data'  # NY Times repo
    return sibling_repo.resolve()


def get_cases_and_deaths():
    #            date    cases  deaths
    # 0    2020-01-21        1       0
    # ..          ...      ...     ...
    # 263  2020-10-10  7748030  214184

    df = pd.read_csv(_get_nyt_covid19_top_dir() / 'us.csv')
    df.date = pd.to_datetime(df.date)

    rows = []
    for i, row in df.iterrows():
        rows.append(dict(date=row.date, stat='cases', val=row.cases))
        rows.append(dict(date=row.date, stat='deaths', val=row.deaths))
    return pd.DataFrame(rows)


def main():
    df = get_cases_and_deaths()
    scale = alt.Scale(type='symlog')
    st.altair_chart(alt.Chart(df)
                    .mark_line()
                    .encode(x=alt.X('date'),
                            y=alt.Y('val', scale=scale),
                            color='stat',
                            strokeDash='stat'))
    print(_now())


if __name__ == '__main__':
    main()<commit_msg>Display linear & log<commit_after>#! /usr/bin/env streamlit run

from pathlib import Path
import datetime as dt

import altair as alt
import pandas as pd
import streamlit as st


def _now():
    return dt.datetime.now().replace(microsecond=0)


def _get_nyt_covid19_top_dir():
    repo_top = Path(__file__ + '/../../..').resolve()
    sibling_repo = repo_top / '../covid-19-data'  # NY Times repo
    return sibling_repo.resolve()


def get_cases_and_deaths():
    #            date    cases  deaths
    # 0    2020-01-21        1       0
    # ..          ...      ...     ...
    # 263  2020-10-10  7748030  214184

    df = pd.read_csv(_get_nyt_covid19_top_dir() / 'us.csv')
    df.date = pd.to_datetime(df.date)

    rows = []
    for i, row in df.iterrows():
        rows.append(dict(date=row.date, stat='cases', val=row.cases))
        rows.append(dict(date=row.date, stat='deaths', val=row.deaths))
    return pd.DataFrame(rows)


def _get_chart(df, scale_type='linear'):
    return (alt.Chart(df)
            .mark_line()
            .encode(x=alt.X('date'),
                    y=alt.Y('val', scale=alt.Scale(type=scale_type)),
                    color='stat',
                    strokeDash='stat'))


def main():
    df = get_cases_and_deaths()
    st.altair_chart(_get_chart(df))
    st.altair_chart(_get_chart(df, 'symlog'))
    print(_now())


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.145007342143906, 'fraction_numerical': 0.030837004405286344, 'mean_word_length': 2.1214203894616266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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}}
{'dir': 'git-commits-cleaned', 'id': '1664241', 'n_tokens_mistral': 1007, 'n_tokens_neox': 928, 'n_words': 188}