Skip to content

Commit ef4496f

Browse files
authored
Merge pull request rapidsai#18834 from rapidsai/branch-25.06
Forward-merge branch-25.06 into branch-25.08
2 parents 782fc70 + 41b9885 commit ef4496f

File tree

14 files changed

+1604
-137
lines changed

14 files changed

+1604
-137
lines changed

python/cudf/cudf/core/_base_index.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from functools import cached_property
77
from typing import TYPE_CHECKING, Any, Literal
88

9-
import numpy as np
109
import pandas as pd
1110
from typing_extensions import Self
1211

@@ -2171,9 +2170,3 @@ def _split(self, splits):
21712170

21722171
def _get_result_name(left_name, right_name):
21732172
return left_name if _is_same_name(left_name, right_name) else None
2174-
2175-
2176-
def _return_get_indexer_result(result: cupy.ndarray) -> cupy.ndarray:
2177-
if cudf.get_option("mode.pandas_compatible"):
2178-
return result.astype(np.dtype(np.int64))
2179-
return result

python/cudf/cudf/core/column/column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@ def as_column(
26622662
if isinstance(arbitrary, cudf.Series):
26632663
arbitrary = arbitrary._column
26642664
elif isinstance(arbitrary, cudf.BaseIndex):
2665-
arbitrary = arbitrary._values
2665+
arbitrary = arbitrary._column
26662666
if dtype is not None:
26672667
return arbitrary.astype(dtype)
26682668
return arbitrary

python/cudf/cudf/core/frame.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,69 @@ def size(self) -> int:
300300
"""
301301
return self._num_columns * self._num_rows
302302

303+
@property
304+
@_performance_tracking
305+
def empty(self):
306+
"""
307+
Indicator whether DataFrame or Series is empty.
308+
309+
True if DataFrame/Series is entirely empty (no items),
310+
meaning any of the axes are of length 0.
311+
312+
Returns
313+
-------
314+
out : bool
315+
If DataFrame/Series is empty, return True, if not return False.
316+
317+
Examples
318+
--------
319+
>>> import cudf
320+
>>> df = cudf.DataFrame({'A' : []})
321+
>>> df
322+
Empty DataFrame
323+
Columns: [A]
324+
Index: []
325+
>>> df.empty
326+
True
327+
328+
If we only have `null` values in our DataFrame, it is
329+
not considered empty! We will need to drop
330+
the `null`'s to make the DataFrame empty:
331+
332+
>>> df = cudf.DataFrame({'A' : [None, None]})
333+
>>> df
334+
A
335+
0 <NA>
336+
1 <NA>
337+
>>> df.empty
338+
False
339+
>>> df.dropna().empty
340+
True
341+
342+
Non-empty and empty Series example:
343+
344+
>>> s = cudf.Series([1, 2, None])
345+
>>> s
346+
0 1
347+
1 2
348+
2 <NA>
349+
dtype: int64
350+
>>> s.empty
351+
False
352+
>>> s = cudf.Series([])
353+
>>> s
354+
Series([], dtype: float64)
355+
>>> s.empty
356+
True
357+
358+
.. pandas-compat::
359+
:attr:`pandas.DataFrame.empty`, :attr:`pandas.Series.empty`
360+
361+
If DataFrame/Series contains only `null` values, it is still not
362+
considered empty. See the example above.
363+
"""
364+
return self.size == 0
365+
303366
def memory_usage(self, deep: bool = False) -> int:
304367
"""Return the memory usage of an object.
305368

python/cudf/cudf/core/groupby/groupby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3625,7 +3625,7 @@ def _handle_frequency_grouper(self, by):
36253625

36263626
def _handle_level(self, by):
36273627
level_values = self._obj.index.get_level_values(by)
3628-
self._key_columns.append(level_values._values)
3628+
self._key_columns.append(level_values._column)
36293629
self.names.append(level_values.name)
36303630

36313631
def _handle_misc(self, by):

0 commit comments

Comments
 (0)