Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated method DataFrame.hash_columns. #9943

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/cudf/source/api_docs/dataframe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ Serialization / IO / conversion
DataFrame.from_arrow
DataFrame.from_pandas
DataFrame.from_records
DataFrame.hash_columns
DataFrame.hash_values
DataFrame.to_arrow
DataFrame.to_dlpack
Expand Down
32 changes: 0 additions & 32 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4227,38 +4227,6 @@ def apply_chunks(
tpb=tpb,
)

def hash_columns(self, columns=None, method="murmur3"):
"""Hash the given *columns* and return a new device array

This method is deprecated. Replace ``df.hash_columns(columns, method)``
with ``df[columns].hash_values(method)``.

Parameters
----------
columns : sequence of str; optional
Sequence of column names. If columns is *None* (unspecified),
all columns in the frame are used.
method : {'murmur3', 'md5'}, default 'murmur3'
Hash function to use:
* murmur3: MurmurHash3 hash function.
* md5: MD5 hash function.

Returns
-------
Series
Hash values for each row.
"""
warnings.warn(
"The `hash_columns` method will be removed in a future cuDF "
"release. Replace `df.hash_columns(columns, method)` with "
"`df[columns].hash_values(method)`.",
FutureWarning,
)
if columns is None:
# Slice by [:] to keep all columns.
columns = slice(None, None, None)
return self[columns].hash_values(method=method)

def hash_values(self, method="murmur3"):
"""Compute the hash of values in each row.

Expand Down
28 changes: 0 additions & 28 deletions python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,34 +1107,6 @@ def test_assign():
np.testing.assert_equal(gdf2.y.to_numpy(), [2, 3, 4])


@pytest.mark.parametrize("nrows", [1, 8, 100, 1000])
@pytest.mark.parametrize("method", ["murmur3", "md5"])
def test_dataframe_hash_columns(nrows, method):
gdf = cudf.DataFrame()
data = np.asarray(range(nrows))
data[0] = data[-1] # make first and last the same
gdf["a"] = data
gdf["b"] = gdf.a + 100
with pytest.warns(FutureWarning):
out = gdf.hash_columns(["a", "b"])
assert isinstance(out, cudf.Series)
assert len(out) == nrows
assert out.dtype == np.int32

# Check default
with pytest.warns(FutureWarning):
out_all = gdf.hash_columns()
assert_eq(out, out_all)

# Check single column
with pytest.warns(FutureWarning):
out_one = gdf.hash_columns(["a"], method=method)
# First matches last
assert out_one.iloc[0] == out_one.iloc[-1]
# Equivalent to the cudf.Series.hash_values()
assert_eq(gdf["a"].hash_values(method=method), out_one)


@pytest.mark.parametrize("nrows", [1, 8, 100, 1000])
@pytest.mark.parametrize("method", ["murmur3", "md5"])
def test_dataframe_hash_values(nrows, method):
Expand Down