Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit c005b9a

Browse files
Remove unused methods _nlargest and _nsmallest from icolumn, numerical_column_cpu, and dataframe_cpu (#415)
Summary: Pull Request resolved: #415 Removes unused private methods in icolumn.py bringing code coverage to 79.2%. Differential Revision: D37503197 fbshipit-source-id: fd8dfe709963b80bb53998d9f9a3da30ed9897dc
1 parent 25b6e4d commit c005b9a

File tree

3 files changed

+0
-75
lines changed

3 files changed

+0
-75
lines changed

torcharrow/icolumn.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,34 +1418,6 @@ def _count(self):
14181418
"""Return number of non-NA/null observations pgf the column/frame"""
14191419
return len(self) - self.null_count
14201420

1421-
@trace
1422-
@expression
1423-
def _nlargest(
1424-
self,
1425-
n=5,
1426-
columns: ty.Optional[ty.List[str]] = None,
1427-
keep: ty.Literal["last", "first"] = "first",
1428-
):
1429-
"""Returns a new data of the *n* largest element."""
1430-
# keep="all" not supported
1431-
if columns is not None:
1432-
raise TypeError(
1433-
"computing n-largest on non-structured column can't have 'columns' parameter"
1434-
)
1435-
return self.sort(ascending=False).head(n)
1436-
1437-
@trace
1438-
@expression
1439-
def _nsmallest(self, n=5, columns: ty.Optional[ty.List[str]] = None, keep="first"):
1440-
"""Returns a new data of the *n* smallest element."""
1441-
# keep="all" not supported
1442-
if columns is not None:
1443-
raise TypeError(
1444-
"computing n-smallest on non-structured column can't have 'columns' parameter"
1445-
)
1446-
1447-
return self.sort(ascending=True).head(n)
1448-
14491421
@trace
14501422
@expression
14511423
def _nunique(self, drop_null=True):

torcharrow/velox_rt/dataframe_cpu.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -617,29 +617,6 @@ def func(tup):
617617
res._extend([None] * self.null_count)
618618
return res._finalize()
619619

620-
@trace
621-
@expression
622-
def _nlargest(
623-
self,
624-
n=5,
625-
columns: Optional[List[str]] = None,
626-
keep="first",
627-
):
628-
"""Returns a new dataframe of the *n* largest elements."""
629-
# Todo add keep arg
630-
return self.sort(by=columns, ascending=False).head(n)
631-
632-
@trace
633-
@expression
634-
def _nsmallest(
635-
self,
636-
n=5,
637-
columns: Optional[List[str]] = None,
638-
keep="first",
639-
):
640-
"""Returns a new dataframe of the *n* smallest elements."""
641-
return self.sort(by=columns, ascending=True).head(n)
642-
643620
# operators --------------------------------------------------------------
644621

645622
@expression

torcharrow/velox_rt/numerical_column_cpu.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -193,30 +193,6 @@ def sort(
193193

194194
return ColumnCpuMixin._from_velox(self.device, self.dtype, col, True)
195195

196-
@trace
197-
@expression
198-
def _nlargest(
199-
self,
200-
n=5,
201-
columns: Optional[List[str]] = None,
202-
keep="first",
203-
):
204-
if columns is not None:
205-
raise TypeError(
206-
"computing n-largest on numerical column can't have 'columns' parameter"
207-
)
208-
return self.sort(columns=None, ascending=False, na_position=keep).head(n)
209-
210-
@trace
211-
@expression
212-
def _nsmallest(self, n=5, columns: Optional[List[str]] = None, keep="first"):
213-
if columns is not None:
214-
raise TypeError(
215-
"computing n-smallest on numerical column can't have 'columns' parameter"
216-
)
217-
218-
return self.sort(columns=None, ascending=True, na_position=keep).head(n)
219-
220196
@trace
221197
@expression
222198
def _nunique(self, drop_null=True):

0 commit comments

Comments
 (0)