Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-b-miller committed Aug 6, 2021
1 parent 0f29b34 commit 296eddc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
17 changes: 8 additions & 9 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,28 +1490,27 @@ def interpolate(
)

data = self
columns = {}

if not isinstance(data._index, cudf.RangeIndex):
perm_sort = data._index.argsort()
data = data._gather(perm_sort)

interpolator = cudf.core.algorithms.get_column_interpolator(method)
columns = {}
for colname, col in data._data.items():
if col.nullable:
col = col.astype("float64").fillna(np.nan)

# Interpolation methods may or may not need the index
result = interpolator(col, index=data._index)
columns[colname] = result

result = self.__class__(ColumnAccessor(columns), index=data._index)
columns[colname] = interpolator(col, index=data._index)

if not isinstance(data._index, cudf.RangeIndex):
# that which was once sorted, now is not
result = result._gather(perm_sort.argsort())
result = self._from_data(columns, index=data._index)

return result
return (
result
if isinstance(data._index, cudf.RangeIndex)
else result._gather(perm_sort.argsort())
)

def _quantiles(
self,
Expand Down
5 changes: 4 additions & 1 deletion python/cudf/cudf/tests/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
@pytest.mark.parametrize("method", ["linear"])
@pytest.mark.parametrize("axis", [0])
def test_interpolate_dataframe(data, method, axis):
# doesn't seem to work with NAs just yet
# Pandas interpolate methods do not seem to work
# with nullable dtypes yet, so this method treats
# NAs as NaNs
# https://github.com/pandas-dev/pandas/issues/40252
gdf = cudf.DataFrame(data)
pdf = gdf.to_pandas()

Expand Down

0 comments on commit 296eddc

Please sign in to comment.