Skip to content

Commit

Permalink
Merge pull request #88 from martindurant/cudf_oldnew
Browse files Browse the repository at this point in the history
have cudf work with new or old versions
  • Loading branch information
martindurant authored Dec 2, 2024
2 parents 6fb58c8 + eccc6af commit 2a7b068
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/akimbo/cudf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def dec_cu(op, match=match_string):
def f(lay, **kwargs):
# op(column, ...)->column
col = op(lay._to_cudf(cudf, None, len(lay)), **kwargs)
return from_cudf(cudf.Series._from_column(col)).layout
if hasattr(cudf.Series, "_from_column"):
return from_cudf(cudf.Series._from_column(col)).layout
return from_cudf(cudf.Series(col)).layout

return dec(func=f, match=match, inmode="ak")

Expand All @@ -60,9 +62,11 @@ def f(lay, **kwargs):
def f(lay, method=meth, **kwargs):
# this is different from dec_cu, because we need to instantiate StringMethods
# before getting the method from it
col = getattr(
StringMethods(cudf.Series._from_column(lay._to_cudf(cudf, None, len(lay)))), method
)(**kwargs)
if hasattr(cudf.Series, "_from_column"):
ser = cudf.Series._from_column(lay._to_cudf(cudf, None, len(lay)))
else:
ser = cudf.Series(lay._to_cudf(cudf, None, len(lay)))
col = getattr(StringMethods(ser), method)(**kwargs)
return from_cudf(col).layout

setattr(CudfStringAccessor, meth, dec(func=f, match=match_string, inmode="ak"))
Expand All @@ -87,7 +91,9 @@ def f(lay, method=meth, **kwargs):
else:
# attributes giving components
col = m
return from_cudf(cudf.Series._from_column(col)).layout
if hasattr(cudf.Series, "_from_column"):
return from_cudf(cudf.Series._from_column(col)).layout
return from_cudf(cudf.Series(col)).layout

if isinstance(getattr(DatetimeColumn, meth), property):
setattr(
Expand Down

0 comments on commit 2a7b068

Please sign in to comment.