Skip to content

Commit 3abd85c

Browse files
committed
Rename split parameter k to first_n
1 parent 8717257 commit 3abd85c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

datascience/tables.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,16 +2346,16 @@ def sample_from_distribution(self, distribution, k, proportions=False):
23462346
label = self._unused_label(self._as_label(distribution) + ' sample')
23472347
return self.with_column(label, sample)
23482348

2349-
def split(self, k):
2349+
def split(self, first_n):
23502350
"""Return a tuple of two tables where the first table contains
2351-
``k`` rows randomly sampled and the second contains the remaining rows.
2351+
``first_n`` rows randomly sampled and the second contains the remaining rows.
23522352
23532353
Args:
2354-
``k`` (int): The number of rows randomly sampled into the first
2355-
table. ``k`` must be between 1 and ``num_rows - 1``.
2354+
``first_n`` (int): The number of rows randomly sampled into the first
2355+
table. ``first_n`` must be between 1 and ``num_rows - 1``.
23562356
23572357
Raises:
2358-
``ValueError``: ``k`` is not between 1 and ``num_rows - 1``.
2358+
``ValueError``: ``first_n`` is not between 1 and ``num_rows - 1``.
23592359
23602360
Returns:
23612361
A tuple containing two instances of ``Table``.
@@ -2379,14 +2379,14 @@ def split(self, k):
23792379
job | wage
23802380
d | 8
23812381
"""
2382-
if not 1 <= k <= self.num_rows - 1:
2383-
raise ValueError("Invalid value of k. k must be between 1 and the"
2382+
if not 1 <= first_n <= self.num_rows - 1:
2383+
raise ValueError("Invalid value of first_n. first_n must be between 1 and the"
23842384
"number of rows - 1")
23852385

23862386
rows = np.random.permutation(self.num_rows)
23872387

2388-
first = self.take(rows[:k])
2389-
rest = self.take(rows[k:])
2388+
first = self.take(rows[:first_n])
2389+
rest = self.take(rows[first_n:])
23902390
for column_label in self._formats:
23912391
first._formats[column_label] = self._formats[column_label]
23922392
rest._formats[column_label] = self._formats[column_label]

0 commit comments

Comments
 (0)