Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

## Bug Fixes

- PR #6073 Fix issue related to `.loc` incase of `DatetimeIndex`
- PR #6081 Fix issue where fsspec thinks it has a protocol string


Expand Down
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda10.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- cmake>=3.14
- cmake_setuptools>=0.1.3
- python>=3.6,<3.8
- numba>=0.49.0
- numba>=0.49.0,!=0.51.0
- numpy
- pandas>=1.0,<1.2.0dev0
- pyarrow=0.17.1
Expand Down Expand Up @@ -50,6 +50,7 @@ dependencies:
- hypothesis
- sphinx-markdown-tables
- sphinx-copybutton
- packaging
- pip:
- git+https://github.com/dask/dask.git
- git+https://github.com/dask/distributed.git
Expand Down
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda10.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- cmake>=3.14
- cmake_setuptools>=0.1.3
- python>=3.6,<3.8
- numba>=0.49.0
- numba>=0.49.0,!=0.51.0
- numpy
- pandas>=1.0,<1.2.0dev0
- pyarrow=0.17.1
Expand Down Expand Up @@ -50,6 +50,7 @@ dependencies:
- hypothesis
- sphinx-markdown-tables
- sphinx-copybutton
- packaging
- pip:
- git+https://github.com/dask/dask.git
- git+https://github.com/dask/distributed.git
Expand Down
3 changes: 2 additions & 1 deletion conda/environments/cudf_dev_cuda10.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- cmake>=3.14
- cmake_setuptools>=0.1.3
- python>=3.6,<3.8
- numba>=0.49.0
- numba>=0.49,!=0.51.0
- numpy
- pandas>=1.0,<1.2.0dev0
- pyarrow=0.17.1
Expand Down Expand Up @@ -50,6 +50,7 @@ dependencies:
- hypothesis
- sphinx-markdown-tables
- sphinx-copybutton
- packaging
- pip:
- git+https://github.com/dask/dask.git
- git+https://github.com/dask/distributed.git
Expand Down
1 change: 1 addition & 0 deletions python/cudf/cudf/core/_compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2020, NVIDIA CORPORATION.

import pandas as pd
from packaging import version

Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/column/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@ def find_first_value(self, value, closest=False):
Returns offset of first value that matches
"""
value = pd.to_datetime(value)
value = column.as_column(value).as_numerical[0]
value = column.as_column(value, dtype=self.dtype).as_numerical[0]
return self.as_numerical.find_first_value(value, closest=closest)

def find_last_value(self, value, closest=False):
"""
Returns offset of last value that matches
"""
value = pd.to_datetime(value)
value = column.as_column(value).as_numerical[0]
value = column.as_column(value, dtype=self.dtype).as_numerical[0]
return self.as_numerical.find_last_value(value, closest=closest)

@property
Expand Down
33 changes: 28 additions & 5 deletions python/cudf/cudf/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,22 @@ def test_series_loc_numerical():
assert_eq(ps.loc[[5, 8, 9]], gs.loc[cupy.array([5, 8, 9])])


def test_series_loc_float_index():
ps = pd.Series([1, 2, 3, 4, 5], index=[5.43, 6.34, 7.34, 8.0, 9.1])
gs = Series.from_pandas(ps)

assert_eq(ps.loc[5.43], gs.loc[5.43])
assert_eq(ps.loc[8], gs.loc[8])
assert_eq(ps.loc[6.1:8], gs.loc[6.1:8])
assert_eq(ps.loc[:7.1], gs.loc[:7.1])
assert_eq(ps.loc[6.345:], gs.loc[6.345:])
assert_eq(ps.loc[::2], gs.loc[::2])
assert_eq(
ps.loc[[True, False, True, False, True]],
gs.loc[[True, False, True, False, True]],
)


def test_series_loc_string():
ps = pd.Series(
[1, 2, 3, 4, 5], index=["one", "two", "three", "four", "five"]
Expand Down Expand Up @@ -411,11 +427,12 @@ def test_series_loc_datetime():
assert_eq(ps.loc["2001-01-02":], gs.loc["2001-01-02":], **kwargs)
assert_eq(ps.loc[:"2001-01-04"], gs.loc[:"2001-01-04"], **kwargs)
assert_eq(ps.loc[::2], gs.loc[::2], **kwargs)
#
# assert_eq(ps.loc[['2001-01-01', '2001-01-04', '2001-01-05']],
# gs.loc[['2001-01-01', '2001-01-04', '2001-01-05']])
# looks like a bug in Pandas doesn't let us check for the above,
# so instead:

assert_eq(
ps.loc[["2001-01-01", "2001-01-04", "2001-01-05"]],
gs.loc[["2001-01-01", "2001-01-04", "2001-01-05"]],
)

assert_eq(
ps.loc[
[
Expand All @@ -438,6 +455,12 @@ def test_series_loc_datetime():
**kwargs,
)

just_less_than_max = ps.index.max() - pd.Timedelta("5m")

assert_eq(
ps.loc[:just_less_than_max], gs.loc[:just_less_than_max], **kwargs
)


def test_series_loc_categorical():
ps = pd.Series(
Expand Down
9 changes: 7 additions & 2 deletions python/cudf/cudf/utils/cudautils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ def gpu_mark_found_int(arr, val, out, not_found):
def gpu_mark_found_float(arr, val, out, not_found):
i = cuda.grid(1)
if i < arr.size:
if check_equals_float(arr[i], val):
# TODO: Remove val typecast to float(val)
# once numba minimum version is pinned
# at 0.51.1, this will have a very slight
# performance improvement. Related
# discussion in : https://github.com/rapidsai/cudf/pull/6073
if check_equals_float(arr[i], float(val)):
out[i] = i
else:
out[i] = not_found
Expand Down Expand Up @@ -144,7 +149,7 @@ def find_index_of_val(arr, val, mask=None, compare="eq"):
mask : mask of the array
compare: str ('gt', 'lt', or 'eq' (default))
"""
found = cuda.device_array_like(arr)
found = cuda.device_array(shape=(arr.shape), dtype="int32")
if found.size > 0:
if compare == "gt":
gpu_mark_gt.forall(found.size)(arr, val, found, arr.size)
Expand Down