Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanhemani committed Jan 29, 2023
1 parent 614db00 commit d29a5d4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
40 changes: 37 additions & 3 deletions datascience/tables.py
Expand Up @@ -288,6 +288,7 @@ def num_rows(self):
integer value stating number of rows
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand All @@ -307,6 +308,7 @@ def rows(self):
list-like Rows object that contains tuple-like Row objects
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand All @@ -322,7 +324,12 @@ def rows(self):
return self.Rows(self)

def row(self, index):
"""Return a row."""
"""
Return a row.
Please see extended docstring at https://github.com/data-8/datascience/blob/614db00e7d22e52683860d2beaa4037bec26cf87/datascience/tables.py#L5673-L5765
for how to interact with Rows.
"""
return self.rows[index]

@property
Expand All @@ -334,6 +341,7 @@ def labels(self):
tuple of labels
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand All @@ -358,6 +366,7 @@ def columns(self):
tuple of columns
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand Down Expand Up @@ -418,6 +427,23 @@ def values(self):
If all columns are the same dtype, the resulting array
will have this dtype. If there are >1 dtypes in columns,
then the resulting array will have dtype `object`.
Example:
>>> tiles = Table().with_columns(
... 'letter', make_array('c', 'd'),
... 'count', make_array(2, 4),
... )
>>> tiles.values
array([['c', 2],
['d', 4]], dtype=object)
>>> t = Table().with_columns(
... 'col1', make_array(1, 2),
... 'col2', make_array(3, 4),
... )
>>> t.values
array([[1, 3],
[2, 4]])
"""
dtypes = [col.dtype for col in self.columns]
if len(set(dtypes)) > 1:
Expand All @@ -437,6 +463,7 @@ def column_index(self, label):
integer value specifying the index of the column label
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand Down Expand Up @@ -519,6 +546,7 @@ def first(self, label):
zeroth item of column
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand All @@ -540,6 +568,7 @@ def last(self, label):
last item of column
Example:
>>> t = Table().with_columns({
... 'letter': ['a', 'b', 'c', 'z'],
... 'count': [ 9, 3, 3, 1],
Expand Down Expand Up @@ -2283,7 +2312,7 @@ def sample(self, k=None, with_replacement=True, weights=None):

def shuffle(self):
"""Return a new table where all the rows are randomly shuffled from the
original table..
original table.
Returns:
A new instance of ``Table`` with all ``k`` rows shuffled.
Expand Down Expand Up @@ -4674,7 +4703,12 @@ def _split_column_and_labels(self, column_or_label):

# Deprecated
def pivot_hist(self, pivot_column_label, value_column_label, overlay=True, width=6, height=4, **vargs):
"""Draw histograms of each category in a column. (Deprecated)"""
"""
Draw histograms of each category in a column. (Deprecated)
Recommended: Use hist(value_column_label, group=pivot_column_label), or with side_by_side=True if you really want side-by-side bars.
"""
warnings.warn("pivot_hist is deprecated; use "
"hist(value_column_label, group=pivot_column_label), or "
"with side_by_side=True if you really want side-by-side "
Expand Down
2 changes: 1 addition & 1 deletion datascience/util.py
Expand Up @@ -249,7 +249,7 @@ def objective(args):
return result.x

def is_non_string_iterable(value):
"""Whether a value is iterable."""
"""Returns a boolean value representing whether a value is iterable."""
if isinstance(value, str):
return False
if hasattr(value, '__iter__'):
Expand Down
6 changes: 0 additions & 6 deletions docs/tables.rst
Expand Up @@ -31,18 +31,12 @@ But these are not valid::
If that syntax is confusing, you can click the method name itself to get to the
details page for that method. That page will have a more straightforward syntax.

At the time of this writing, most methods only have one or two sentences of
documentation, so what you see here is all that you'll get for the time being.
We are actively working on documentation, prioritizing the most complicated
methods (mostly visualizations).

Creation

.. autosummary::
:toctree: _autosummary

Table.__init__
Table.empty
Table.from_records
Table.from_columns_dict
Table.read_table
Expand Down

0 comments on commit d29a5d4

Please sign in to comment.