Skip to content

Commit

Permalink
Address PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Mar 18, 2022
1 parent 25b5df9 commit 21b7ef2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 12 additions & 5 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def __init__(

self._data = new_df._data
self._index = new_df._index
self._check_data_index_length_match()
elif hasattr(data, "__array_interface__"):
arr_interface = data.__array_interface__
if len(arr_interface["descr"]) == 1:
Expand All @@ -622,6 +623,7 @@ def __init__(
new_df = self.from_records(data, index=index, columns=columns)
self._data = new_df._data
self._index = new_df._index
self._check_data_index_length_match()
else:
if is_list_like(data):
if len(data) > 0 and is_scalar(data[0]):
Expand All @@ -633,6 +635,7 @@ def __init__(

self._data = new_df._data
self._index = new_df._index
self._check_data_index_length_match()
elif len(data) > 0 and isinstance(data[0], Series):
self._init_from_series_list(
data=data, columns=columns, index=index
Expand All @@ -650,14 +653,18 @@ def __init__(
data, index=index, columns=columns, nan_as_null=nan_as_null
)

if self._data.nrows > 0 and self._data.nrows != len(self._index):
raise ValueError(
f"Shape of passed values is {self.shape}, indices imply "
f"({len(self._index)}, {self._num_columns})"
)
if dtype:
self._data = self.astype(dtype)._data

def _check_data_index_length_match(df: DataFrame) -> None:
# Validate that the number of rows in the data matches the index if the
# data is not empty. This is a helper for the constructor.
if df._data.nrows > 0 and df._data.nrows != len(df._index):
raise ValueError(
f"Shape of passed values is {df.shape}, indices imply "
f"({len(df._index)}, {df._num_columns})"
)

@_cudf_nvtx_annotate
def _init_from_series_list(self, data, columns, index):
if index is None:
Expand Down
2 changes: 2 additions & 0 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ def equals(self, other):
>>> df.equals(different_column_type)
True
"""
if self is other:
return True
if (
other is None
or not isinstance(other, type(self))
Expand Down

0 comments on commit 21b7ef2

Please sign in to comment.