Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __repr__ for Column and ColumnAccessor #7531

Merged
merged 2 commits into from
Mar 12, 2021
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
7 changes: 7 additions & 0 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ def mask_array_view(self) -> "cuda.devicearray.DeviceNDArray":
def __len__(self) -> int:
return self.size

def __repr__(self):
return (
f"{object.__repr__(self)}\n"
f"{self.to_arrow().to_string()}\n"
f"dtype: {self.dtype}"
)

def to_pandas(
self, index: ColumnLike = None, nullable: bool = False, **kwargs
) -> "pd.Series":
Expand Down
16 changes: 8 additions & 8 deletions python/cudf/cudf/core/column_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ def __len__(self) -> int:
return len(self._data)

def __repr__(self) -> str:
data_repr = self._data.__repr__()
multiindex_repr = self.multiindex.__repr__()
level_names_repr = self.level_names.__repr__()
return "{}({}, multiindex={}, level_names={})".format(
self.__class__.__name__,
data_repr,
multiindex_repr,
level_names_repr,
type_info = (
f"{self.__class__.__name__}("
f"multiindex={self.multiindex}, "
f"level_names={self.level_names})"
)
column_info = "\n".join(
[f"{name}: {col.dtype}" for name, col in self.items()]
)
return f"{type_info}\n{column_info}"

@property
def level_names(self) -> Tuple[Any, ...]:
Expand Down
5 changes: 3 additions & 2 deletions python/cudf/cudf/utils/cudautils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright (c) 2018-2021, NVIDIA CORPORATION.
from pickle import dumps

import cachetools
import cupy
import numpy as np
from numba import cuda
from pickle import dumps

import cudf
from cudf.utils.utils import check_equals_float, check_equals_int
Expand Down Expand Up @@ -239,7 +240,7 @@ def grouped_window_sizes_from_offset(arr, group_starts, offset):
# it can hit for distinct functions that are similar. The lru_cache wrapping
# compile_udf misses for these similar functions, but doesn't need to serialize
# closure variables to check for a hit.
_udf_code_cache = cachetools.LRUCache(maxsize=32)
_udf_code_cache: cachetools.LRUCache = cachetools.LRUCache(maxsize=32)


def compile_udf(udf, type_signature):
Expand Down