From 59d5b4d61bf85ba3e3e2426e00effef74b6d0225 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Tue, 25 May 2021 13:55:16 -0400 Subject: [PATCH] Add aliases for string methods --- python/cudf/cudf/core/column/string.py | 4 ++++ python/cudf/cudf/tests/test_string.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index 940b38ef5ff..a8ae74bdd4b 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -259,6 +259,8 @@ def htoi(self) -> ParentType: return self._return_or_inplace(out, inplace=False) + hex_to_int = htoi + def ip2int(self) -> ParentType: """ This converts ip strings to integers @@ -290,6 +292,8 @@ def ip2int(self) -> ParentType: return self._return_or_inplace(out, inplace=False) + ip_to_int = ip2int + def __getitem__(self, key): if isinstance(key, slice): return self.slice(start=key.start, stop=key.stop, step=key.step) diff --git a/python/cudf/cudf/tests/test_string.py b/python/cudf/cudf/tests/test_string.py index 054bfa15f9b..7be64bedcd7 100644 --- a/python/cudf/cudf/tests/test_string.py +++ b/python/cudf/cudf/tests/test_string.py @@ -2526,9 +2526,12 @@ def test_string_hex_to_int(data): gsr = cudf.Series(data) - got = gsr.str.htoi() expected = cudf.Series([263988422296292, 0, 281474976710655]) + got = gsr.str.htoi() + assert_eq(expected, got) + + got = gsr.str.hex_to_int() # alias assert_eq(expected, got) @@ -2585,7 +2588,9 @@ def test_string_ip4_to_int(): expected = cudf.Series([0, None, 0, 698875905, 2130706433, 700776449]) got = gsr.str.ip2int() + assert_eq(expected, got) + got = gsr.str.ip_to_int() # alias assert_eq(expected, got)