py-datatable

How to modify/update column values on a condition in Pydatatable?

巧了我就是萌 提交于 2021-02-08 04:15:53
问题 In pydatatable, I'm trying to modify a column values specifying a condition in i i.e DT[i=="text", j="some"] sample DT: py_DT= dt.Frame({'crossing':['ABC','A','B','B','A','A','ABC'], 'total' :[2,4,5,6,8,10,12]}) Here i would like to replace crossing value 'ABC' with 'A' only, for that i have written a below sample code, Attempt 1: py_DT[f.crossing=="ABC", f.crossing=="A"] Attempt 2: py_DT[f.crossing=="ABC", update(f.crossing=="A")] None of these attempts were worked out, is there any other

How to modify/update column values on a condition in Pydatatable?

时光毁灭记忆、已成空白 提交于 2021-02-08 04:15:50
问题 In pydatatable, I'm trying to modify a column values specifying a condition in i i.e DT[i=="text", j="some"] sample DT: py_DT= dt.Frame({'crossing':['ABC','A','B','B','A','A','ABC'], 'total' :[2,4,5,6,8,10,12]}) Here i would like to replace crossing value 'ABC' with 'A' only, for that i have written a below sample code, Attempt 1: py_DT[f.crossing=="ABC", f.crossing=="A"] Attempt 2: py_DT[f.crossing=="ABC", update(f.crossing=="A")] None of these attempts were worked out, is there any other

How to modify/update column values on a condition in Pydatatable?

北城以北 提交于 2021-02-08 04:15:27
问题 In pydatatable, I'm trying to modify a column values specifying a condition in i i.e DT[i=="text", j="some"] sample DT: py_DT= dt.Frame({'crossing':['ABC','A','B','B','A','A','ABC'], 'total' :[2,4,5,6,8,10,12]}) Here i would like to replace crossing value 'ABC' with 'A' only, for that i have written a below sample code, Attempt 1: py_DT[f.crossing=="ABC", f.crossing=="A"] Attempt 2: py_DT[f.crossing=="ABC", update(f.crossing=="A")] None of these attempts were worked out, is there any other

How to modify/update column values on a condition in Pydatatable?

大城市里の小女人 提交于 2021-02-08 04:14:52
问题 In pydatatable, I'm trying to modify a column values specifying a condition in i i.e DT[i=="text", j="some"] sample DT: py_DT= dt.Frame({'crossing':['ABC','A','B','B','A','A','ABC'], 'total' :[2,4,5,6,8,10,12]}) Here i would like to replace crossing value 'ABC' with 'A' only, for that i have written a below sample code, Attempt 1: py_DT[f.crossing=="ABC", f.crossing=="A"] Attempt 2: py_DT[f.crossing=="ABC", update(f.crossing=="A")] None of these attempts were worked out, is there any other

How to filter observations for the multiple values passed in the I expression of Pydatatable frame?

假如想象 提交于 2020-07-22 18:46:33
问题 I have a data frame with two columns as shown below, DT_EX = dt.Frame({'film':['Don','Warriors','Dragon','Chicago','Lion','Don','Chicago','Warriors'], 'gross':[400,500,600,100,200,300,900,1000]}) Here in first case i would like to filter the observations whose film is Don or Chicago as written in below code, DT_EX[((f.film=="Don") | (f.film=="Chicago")),:] In a second i would apply filter for 3 values as, DT_EX[((f.film=="Don") | (f.film=="Chicago") | (f.film=="Lion")),:] In case of filtering

How to filter observations for the multiple values passed in the I expression of Pydatatable frame?

五迷三道 提交于 2020-07-22 18:46:10
问题 I have a data frame with two columns as shown below, DT_EX = dt.Frame({'film':['Don','Warriors','Dragon','Chicago','Lion','Don','Chicago','Warriors'], 'gross':[400,500,600,100,200,300,900,1000]}) Here in first case i would like to filter the observations whose film is Don or Chicago as written in below code, DT_EX[((f.film=="Don") | (f.film=="Chicago")),:] In a second i would apply filter for 3 values as, DT_EX[((f.film=="Don") | (f.film=="Chicago") | (f.film=="Lion")),:] In case of filtering

Python data.table row filter by regex

北战南征 提交于 2020-06-23 08:14:12
问题 What is the data.table for python equivalent of %like%? Short example: dt_foo_bar = dt.Frame({"n": [1, 3], "s": ["foo", "bar"]}) dt_foo_bar[re.match("foo",f.s),:] #works to filter by "foo" I had expected something like this to work: dt_foo_bar[re.match("fo",f.s),:] But it returns "expected string or bytes-like object". I'd love to start using the new data.tables package in Python the way I use it in R but I work a lot more with text data than numeric. Thanks in advance. 回答1: Since version 0.9

Python data.table row filter by regex

我与影子孤独终老i 提交于 2020-06-23 08:07:24
问题 What is the data.table for python equivalent of %like%? Short example: dt_foo_bar = dt.Frame({"n": [1, 3], "s": ["foo", "bar"]}) dt_foo_bar[re.match("foo",f.s),:] #works to filter by "foo" I had expected something like this to work: dt_foo_bar[re.match("fo",f.s),:] But it returns "expected string or bytes-like object". I'd love to start using the new data.tables package in Python the way I use it in R but I work a lot more with text data than numeric. Thanks in advance. 回答1: Since version 0.9