Skip to content

Commit

Permalink
Allow melt(var_name=) to be a falsy label (#16981)
Browse files Browse the repository at this point in the history
closes #16972

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #16981
  • Loading branch information
mroeschke authored Oct 4, 2024
1 parent 39342b8 commit d15bbfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def _tile(A, reps):
nval = len(value_vars)
dtype = min_unsigned_type(nval)

if not var_name:
if var_name is None:
var_name = "variable"

if not value_vars:
Expand Down
9 changes: 9 additions & 0 deletions python/cudf/cudf/tests/test_reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ def test_melt_str_scalar_id_var():
assert_eq(result, expected)


def test_melt_falsy_var_name():
df = cudf.DataFrame({"A": ["a", "b", "c"], "B": [1, 3, 5], "C": [2, 4, 6]})
result = cudf.melt(df, id_vars=["A"], value_vars=["B"], var_name="")
expected = pd.melt(
df.to_pandas(), id_vars=["A"], value_vars=["B"], var_name=""
)
assert_eq(result, expected)


@pytest.mark.parametrize("num_cols", [1, 2, 10])
@pytest.mark.parametrize("num_rows", [1, 2, 1000])
@pytest.mark.parametrize(
Expand Down

0 comments on commit d15bbfd

Please sign in to comment.