Skip to content

Commit

Permalink
Fix DataFrame.values with no columns but index (#14134)
Browse files Browse the repository at this point in the history
Fixes the following

```python
In [32]: cudf.DataFrame(index=range(10)).values
Out[32]: array([], shape=(0, 0), dtype=float64)
```

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

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #14134
  • Loading branch information
mroeschke authored Sep 20, 2023
1 parent 2d4f22a commit 7b0693f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def get_column_values_na(col):
ncol = self._num_columns
if ncol == 0:
return make_empty_matrix(
shape=(0, 0), dtype=np.dtype("float64"), order="F"
shape=(len(self), ncol), dtype=np.dtype("float64"), order="F"
)

if dtype is None:
Expand Down
6 changes: 6 additions & 0 deletions python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -10374,3 +10374,9 @@ def test_dataframe_init_from_nested_dict():
pdf = pd.DataFrame(regular_dict)
gdf = cudf.DataFrame(regular_dict)
assert_eq(pdf, gdf)


def test_data_frame_values_no_cols_but_index():
result = cudf.DataFrame(index=range(5)).values
expected = pd.DataFrame(index=range(5)).values
assert_eq(result, expected)

0 comments on commit 7b0693f

Please sign in to comment.