Python data.table按正则表达式进行的行筛选器

Python data.table按正则表达式进行的行筛选器,python,py-datatable,Python,Py Datatable,python的data.table与%like%的等效值是什么 简短示例: dt_foo_bar = dt.Frame({"n": [1, 3], "s": ["foo", "bar"]}) dt_foo_bar[re.match("foo",f.s),:] #works to filter by "foo" 我本以为这样的事情会奏效: dt_foo_bar[re.match("fo",f.s),:] 但它返回“预期的字符串或字节,如对象”。 我很想在Python中开始使用新的data

python的data.table与%like%的等效值是什么

简短示例:

dt_foo_bar = dt.Frame({"n": [1, 3], "s": ["foo", "bar"]})  
dt_foo_bar[re.match("foo",f.s),:] #works to filter by "foo"
我本以为这样的事情会奏效:

dt_foo_bar[re.match("fo",f.s),:] 
但它返回“预期的字符串或字节,如对象”。 我很想在Python中开始使用新的data.tables包,就像我在R中使用它一样,但我更多地使用文本数据,而不是数字数据


提前感谢。

自0.9.0版以来,datatable包含执行正则表达式筛选的函数
.re_match()
。例如:

>>> import datatable as dt
>>> dt_foo_bar = dt.Frame(N=[1, 3, 5], S=["foo", "bar", "fox"])
>>> dt_foo_bar[dt.f.S.re_match("fo."), :]
     N  S  
--  --  ---
 0   1  foo
 1   5  fox

[2 rows x 2 columns]

通常,
.re_match()
应用于列表达式并生成一个新的布尔列,指示每个值是否与给定的正则表达式匹配。

我在文档中找不到此功能或任何与字符串相关的数据处理。您还知道如何基于正则表达式生成新列吗?我现在使用这个,但它看起来不像是to_list转换的最佳方式:DT['new_name']=Frame([re.sub('some_regex_pattern','value_for_new_column',s)for s in DT[:,“column_for_regex”]。@Zappageck我恐怕现在不可能