示例#1
0
 def test_chain(self):
     func = StringChain(columns=["coq_word_label_1", "coq_source_genre_1"],
                        value=" ")
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(
         val.tolist(),
         ["abc SPOK", "abc NEWS", "abc NEWS", "x SPOK", "x NEWS"])
示例#2
0
 def test_freq(self):
     df = pd.DataFrame(df0)
     func = Freq(columns=[
         x for x in df.columns if not x.startswith("coquery_invisible")
     ])
     val = FunctionList([func]).lapply(df, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [1, 2, 2, 1, 1])
示例#3
0
 def test_chain(self):
     func = StringChain(
         columns=["coq_word_label_1", "coq_source_genre_1"],
         value=" ")
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(
         val.tolist(),
         ["abc SPOK", "abc NEWS", "abc NEWS", "x SPOK", "x NEWS"])
示例#4
0
 def test_freq_with_nan1(self):
     df = pd.DataFrame(df0)
     df["coq_test_label_1"] = [pd.np.nan, "A", pd.np.nan, "B", pd.np.nan]
     func = Freq(columns=["coq_word_label_1", "coq_test_label_1"])
     val = FunctionList([func]).lapply(df, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [2, 1, 2, 1, 1])
示例#5
0
 def test_freq(self):
     df = pd.DataFrame(df0)
     func = Freq(columns=[x for x in df.columns
                          if not x.startswith("coquery_invisible")])
     val = FunctionList([func]).lapply(df, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [1, 2, 2, 1, 1])
示例#6
0
 def test_match_null(self):
     func = StringMatch(columns=["coq_word_label_2"], value="[a]")
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(
         val.tolist(), [True, True, True, True, False])
示例#7
0
 def test_length(self):
     func = StringLength(columns=["coq_word_label_1"])
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [3, 3, 3, 1, 1])
示例#8
0
 def test_count(self):
     func = StringCount(columns=["coq_word_label_1"], value="x")
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [0, 0, 0, 1, 1])
示例#9
0
 def test_match_null(self):
     func = StringMatch(columns=["coq_word_label_2"], value="[a]")
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [True, True, True, True, False])
示例#10
0
 def test_length(self):
     func = StringLength(columns=["coq_word_label_1"])
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [3, 3, 3, 1, 1])
示例#11
0
 def test_count(self):
     func = StringCount(columns=["coq_word_label_1"], value="x")
     val = FunctionList([func]).lapply(df0, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [0, 0, 0, 1, 1])
示例#12
0
 def test_freq_with_nan1(self):
     df = pd.DataFrame(df0)
     df["coq_test_label_1"] = [pd.np.nan, "A", pd.np.nan, "B", pd.np.nan]
     func = Freq(columns=["coq_word_label_1", "coq_test_label_1"])
     val = FunctionList([func]).lapply(df, session=None)[func.get_id()]
     self.assertListEqual(val.tolist(), [2, 1, 2, 1, 1])