<gh_stars>0
"""
    Description: Filters out all authors not in the specified list
    Example usage: python3 filter_authors.py -i dataset.csv -o filtered_authors.csv
    Author: <NAME>
"""

import argparse
import pandas as pd

names = [

    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME> (<NAME>)",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "Sappho",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",

]
names = list(set(names))


def countPoems(df, author):
    """ Returns number of poems written by the given author """
    mask = (df["Author"] == author)
    return len(df[mask]) 


if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("-i", "--input", required = True)
    parser.add_argument("-o", "--output", required = True)
    args = parser.parse_args()

    PATH_IN = args.input
    PATH_OUT = args.output

    df = pd.read_csv(PATH_IN)

    print("Number of authors chosen: {}".format(len(names)))

    total = 0
    for name in names:
        n = countPoems(df, name)
        print(f"Name: {name} | Poems: {n}")
        total += n

    print(f"Number of poems by the chosen authors: {total}")

    # Select only these poems
    df = df[df["Author"].isin(names)]

    df.reset_index(drop = True, inplace = True)
    df.to_csv(PATH_OUT, index = False)
"""
    Description: Filters out all authors not in the specified list
    Example usage: python3 filter_authors.py -i dataset.csv -o filtered_authors.csv
    Author: <NAME>
"""

import argparse
import pandas as pd

names = [

    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME> (<NAME>)",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "Sappho",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",
    "<NAME>",

]
names = list(set(names))


def countPoems(df, author):
    """ Returns number of poems written by the given author """
    mask = (df["Author"] == author)
    return len(df[mask]) 


if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("-i", "--input", required = True)
    parser.add_argument("-o", "--output", required = True)
    args = parser.parse_args()

    PATH_IN = args.input
    PATH_OUT = args.output

    df = pd.read_csv(PATH_IN)

    print("Number of authors chosen: {}".format(len(names)))

    total = 0
    for name in names:
        n = countPoems(df, name)
        print(f"Name: {name} | Poems: {n}")
        total += n

    print(f"Number of poems by the chosen authors: {total}")

    # Select only these poems
    df = df[df["Author"].isin(names)]

    df.reset_index(drop = True, inplace = True)
    df.to_csv(PATH_OUT, index = False)
Description: Filters out all authors not in the specified list     Example usage: python3 filter_authors.py -i dataset.csv -o filtered_authors.csv     Author: <NAME> Returns number of poems written by the given author # Select only these poems