Пример #1
0
    def test_columns(self):
        df = read_occurrence_dataframe(self.f)

        self.assertCountEqual(df.columns, [
            "buenosaires_usuarios",
            "buenosaires_ocurrencias",
            "cant_palabra",
            "cant_usuarios",
            "cant_provincias",
        ])
Пример #2
0
    def setUp(self):
        contents = """
palabra,a_ocurrencias,a_usuarios,b_ocurrencias,b_usuarios
no1,4,1,0,0
no2,7,1,0,0
no3,100,1,20,1
ok1,5,3,0,0
ok2,3,1,3,2
ok3,10,2,20,3
"""
        self.f = StringIO(contents)
        self.df = read_occurrence_dataframe(self.f, filter_words=(5, 3))
def generate_lists(input_path="output/provinces_words.csv",
                   output_path="output/listados/"):
    """
    Generate ordered lists for each metric words and users

    Params:
    -------
    input_path: string (default="output/provinces_words.csv")
        Path to word-provinces matrix
    """
    print("Loading words from {}".format(input_path))

    df = read_occurrence_dataframe(input_path, filter_words=True)

    add_info(df)

    df.to_csv(os.path.join(output_path, "listado_completo.csv"))

    save_lists(df, output_path)
Пример #4
0
    def test_no_provinces(self):
        df = read_occurrence_dataframe(self.f)

        self.assertEqual(df.loc["uno"].cant_provincias, 1)
        self.assertEqual(df.loc["dos"].cant_provincias, 1)
        self.assertEqual(df.loc["tres"].cant_provincias, 2)
Пример #5
0
    def test_no_ocurrences(self):
        df = read_occurrence_dataframe(self.f)

        self.assertEqual(df.loc["uno"].cant_palabra, 1)
        self.assertEqual(df.loc["dos"].cant_palabra, 1)
        self.assertEqual(df.loc["tres"].cant_palabra, 4)
Пример #6
0
    def test_no_users(self):
        df = read_occurrence_dataframe(self.f)

        self.assertEqual(df.loc["uno"].cant_usuarios, 1)
        self.assertEqual(df.loc["dos"].cant_usuarios, 1)
        self.assertEqual(df.loc["tres"].cant_usuarios, 3)
Пример #7
0
    def test_dataframe_has_three_rows(self):
        """It should remove empty word!"""
        df = read_occurrence_dataframe(self.f)

        self.assertEqual(len(df), 3)
Пример #8
0
    def test_dataframe_has_no_rows(self):
        df = read_occurrence_dataframe(self.f)

        self.assertEqual(len(df), 0)