Skip to content

Commit

Permalink
Fix DataFrame.values with no columns but index
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Sep 19, 2023
1 parent c016b58 commit f4478d1
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 = cupy.empty((5, 0), dtype=np.dtype("float64"), order="F")
assert_eq(result, expected)

0 comments on commit f4478d1

Please sign in to comment.