ci_mapping/analysis/descriptive_analysis.py
def papers_in_journals_and_conferences(
    data, journals, conferences, top_n, filename="papers_in_journals_and_conferences",
):
    """Annual publications in conferences and journals.

    Args:
        data (`pd.DataFrame`): MAG paper data.
        journals (`pd.DataFrame`): Academic journals.
        conferences (`pd.DataFrame`): Academic conferences.
        top_n (int): Number of most used journals and conferences to plot.
        filename (str): Name of the HTML file to store the plot.

    """
    # Merge journals with mag_papers
    paper_journal = data[["id", "year", "type"]].merge(
        journals, left_on="id", right_on="paper_id"
    )

    # Merge conferences with mag_papers
    paper_conference = data[["id", "year", "type"]].merge(
        conferences, left_on="id", right_on="paper_id"
    )

    # Journals
    annual_papers_in_journals = pd.DataFrame(
        paper_journal.groupby(["year", "journal_name"])["paper_id"].count()
    ).reset_index()
    annual_papers_in_journals = annual_papers_in_journals.astype({"year": "int"})

    # Conferences
    annual_papers_in_conferences = pd.DataFrame(
        paper_conference.groupby(["year", "conference_name"])["paper_id"].count()
    ).reset_index()
    annual_papers_in_conferences = annual_papers_in_conferences.astype({"year": "int"})

    # Plot
    slider = alt.binding_range(min=2000, max=2020, step=1)
    year = alt.selection_single(
        name="selected", fields=["year"], bind=slider, init={"year": 2000}
    )

    j = (
        alt.Chart(annual_papers_in_journals)
        .mark_bar()
        .encode(
            x=alt.Y("paper_id", title="Count", scale=alt.Scale(domain=[0, 90])),
            y=alt.X("journal_name", title="Journal name", sort="-x"),
        )
        .properties(width=500, height=300, title="Publications in journals")
        .add_selection(year)
        .transform_filter(year)
        .transform_window(
            row_number="row_number(paper_id)",
            sort=[alt.SortField("paper_id", order="descending")],
        )
        .transform_filter((alt.datum.row_number <= 25))
    )

    c = (
        alt.Chart(annual_papers_in_conferences)
        .mark_bar()
        .encode(
            x=alt.Y("paper_id", title="Count", scale=alt.Scale(domain=[0, 90])),
            y=alt.X("conference_name", title="Conference name", sort="-x"),
        )
        .properties(width=500, height=300, title="Publications in conferences")
        .add_selection(year)
        .transform_filter(year)
        .transform_window(
            row_number="row_number(paper_id)",
            sort=[alt.SortField("paper_id", order="descending")],
        )
        .transform_filter((alt.datum.row_number <= 25))
    )

    alt.hconcat(j, c).save(f"{ci_mapping.project_dir}/reports/figures/{filename}.html")
    logger.info(f"Stored {filename} plot.")
Annual publications in conferences and journals.

    Args:
        data (`pd.DataFrame`): MAG paper data.
        journals (`pd.DataFrame`): Academic journals.
        conferences (`pd.DataFrame`): Academic conferences.
        top_n (int): Number of most used journals and conferences to plot.
        filename (str): Name of the HTML file to store the plot.

    
Annual publications in conferences and journals.
Annual publications in conferences and journals .
def papers_in_journals_and_conferences(
    data, journals, conferences, top_n, filename="papers_in_journals_and_conferences",
):
    paper_journal = data[["id", "year", "type"]].merge(
        journals, left_on="id", right_on="paper_id"
    )
    paper_conference = data[["id", "year", "type"]].merge(
        conferences, left_on="id", right_on="paper_id"
    )
    annual_papers_in_journals = pd.DataFrame(
        paper_journal.groupby(["year", "journal_name"])["paper_id"].count()
    ).reset_index()
    annual_papers_in_journals = annual_papers_in_journals.astype({"year": "int"})
    annual_papers_in_conferences = pd.DataFrame(
        paper_conference.groupby(["year", "conference_name"])["paper_id"].count()
    ).reset_index()
    annual_papers_in_conferences = annual_papers_in_conferences.astype({"year": "int"})
    slider = alt.binding_range(min=2000, max=2020, step=1)
    year = alt.selection_single(
        name="selected", fields=["year"], bind=slider, init={"year": 2000}
    )
    j = (
        alt.Chart(annual_papers_in_journals)
        .mark_bar()
        .encode(
            x=alt.Y("paper_id", title="Count", scale=alt.Scale(domain=[0, 90])),
            y=alt.X("journal_name", title="Journal name", sort="-x"),
        )
        .properties(width=500, height=300, title="Publications in journals")
        .add_selection(year)
        .transform_filter(year)
        .transform_window(
            row_number="row_number(paper_id)",
            sort=[alt.SortField("paper_id", order="descending")],
        )
        .transform_filter((alt.datum.row_number <= 25))
    )
    c = (
        alt.Chart(annual_papers_in_conferences)
        .mark_bar()
        .encode(
            x=alt.Y("paper_id", title="Count", scale=alt.Scale(domain=[0, 90])),
            y=alt.X("conference_name", title="Conference name", sort="-x"),
        )
        .properties(width=500, height=300, title="Publications in conferences")
        .add_selection(year)
        .transform_filter(year)
        .transform_window(
            row_number="row_number(paper_id)",
            sort=[alt.SortField("paper_id", order="descending")],
        )
        .transform_filter((alt.datum.row_number <= 25))
    )
    alt.hconcat(j, c).save(f"{ci_mapping.project_dir}/reports/figures/{filename}.html")
    logger.info(f"Stored {filename} plot.")
def papers_in_journals_and_conferences ( data , journals , conferences , top_n , filename = "papers_in_journals_and_conferences" , ) : paper_journal = data [ [ "id" , "year" , "type" ] ] . merge ( journals , left_on = "id" , right_on = "paper_id" ) paper_conference = data [ [ "id" , "year" , "type" ] ] . merge ( conferences , left_on = "id" , right_on = "paper_id" ) annual_papers_in_journals = pd . DataFrame ( paper_journal . groupby ( [ "year" , "journal_name" ] ) [ "paper_id" ] . count ( ) ) . reset_index ( ) annual_papers_in_journals = annual_papers_in_journals . astype ( { "year" : "int" } ) annual_papers_in_conferences = pd . DataFrame ( paper_conference . groupby ( [ "year" , "conference_name" ] ) [ "paper_id" ] . count ( ) ) . reset_index ( ) annual_papers_in_conferences = annual_papers_in_conferences . astype ( { "year" : "int" } ) slider = alt . binding_range ( min = 2000 , max = 2020 , step = 1 ) year = alt . selection_single ( name = "selected" , fields = [ "year" ] , bind = slider , init = { "year" : 2000 } ) j = ( alt . Chart ( annual_papers_in_journals ) . mark_bar ( ) . encode ( x = alt . Y ( "paper_id" , title = "Count" , scale = alt . Scale ( domain = [ 0 , 90 ] ) ) , y = alt . X ( "journal_name" , title = "Journal name" , sort = "-x" ) , ) . properties ( width = 500 , height = 300 , title = "Publications in journals" ) . add_selection ( year ) . transform_filter ( year ) . transform_window ( row_number = "row_number(paper_id)" , sort = [ alt . SortField ( "paper_id" , order = "descending" ) ] , ) . transform_filter ( ( alt . datum . row_number <= 25 ) ) ) c = ( alt . Chart ( annual_papers_in_conferences ) . mark_bar ( ) . encode ( x = alt . Y ( "paper_id" , title = "Count" , scale = alt . Scale ( domain = [ 0 , 90 ] ) ) , y = alt . X ( "conference_name" , title = "Conference name" , sort = "-x" ) , ) . properties ( width = 500 , height = 300 , title = "Publications in conferences" ) . add_selection ( year ) . transform_filter ( year ) . transform_window ( row_number = "row_number(paper_id)" , sort = [ alt . SortField ( "paper_id" , order = "descending" ) ] , ) . transform_filter ( ( alt . datum . row_number <= 25 ) ) ) alt . hconcat ( j , c ) . save ( f"{ci_mapping.project_dir}/reports/figures/{filename}.html" ) logger . info ( f"Stored {filename} plot." )
Annual publications in conferences and journals.
Annual publications in conferences and journals .
"""Annual publications in conferences and journals.

    Args:
        data (`pd.DataFrame`): MAG paper data.
        journals (`pd.DataFrame`): Academic journals.
        conferences (`pd.DataFrame`): Academic conferences.
        top_n (int): Number of most used journals and conferences to plot.
        filename (str): Name of the HTML file to store the plot.

    """ # Merge journals with mag_papers # Merge conferences with mag_papers # Journals # Conferences # Plot
data
MAG paper data.
MAG paper data .
journals
None
conferences
None
top_n
Number of most used journals and conferences to plot.
Number of most used journals and conferences to plot .
filename
Name of the HTML file to store the plot.
Name of the HTML file to store the plot .