From 5f0ab9eccc1015110f2767a02f086d29c882d067 Mon Sep 17 00:00:00 2001 From: Savithri K B Date: Thu, 11 Jun 2020 22:28:20 -0400 Subject: [PATCH 1/2] docs: Added more details to some docstrings Added documentation for methods from_records, _with_columns, and from_array in tables.py --- datascience/tables.py | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/datascience/tables.py b/datascience/tables.py index a1286bed2..604b9c781 100644 --- a/datascience/tables.py +++ b/datascience/tables.py @@ -86,7 +86,19 @@ def from_rows(cls, rows, labels): @classmethod def from_records(cls, records): - """Create a table from a sequence of records (dicts with fixed keys).""" + """Create a table from a sequence of records (dicts with fixed keys). + + Args: + + records: A list of dictionaries with same keys. + + Returns: + + If the list is empty, it will return an empty table. + Otherwise, it will return a table with the labels as the column name, and the corresponding data. + If the dictionaries do not have identical keys, the keys of the first dictionary in the list is used. + + """ if not records: return cls() labels = sorted(list(records[0].keys())) @@ -126,7 +138,16 @@ def read_table(cls, filepath_or_buffer, *args, **vargs): return cls.from_df(df) def _with_columns(self, columns): - """Create a table from a sequence of columns, copying column labels.""" + """Create a table from a sequence of columns, copying column labels. + + Args: + + columns: A sequence of coloumns with labels + + Returns: + + It returns a table with the input columns containing labels. + """ table = type(self)() for label, column in zip(self.labels, columns): self._add_column_and_format(table, label, column) @@ -158,7 +179,16 @@ def from_df(cls, df, keep_index=False): @classmethod def from_array(cls, arr): - """Convert a structured NumPy array into a Table.""" + """Convert a structured NumPy array into a Table. + + Args: + + arr: A structured numpy array + + Returns: + + A table with the field names as the column names and the corresponding data. + """ return cls().with_columns([(f, arr[f]) for f in arr.dtype.names]) ################# From 849a4224005f8cfc6b60b2fa6ad4b914e35ef3a5 Mon Sep 17 00:00:00 2001 From: Savithri K B Date: Mon, 15 Jun 2020 22:01:04 -0400 Subject: [PATCH 2/2] docs: Removed documentation from private function --- datascience/tables.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/datascience/tables.py b/datascience/tables.py index 604b9c781..befab9878 100644 --- a/datascience/tables.py +++ b/datascience/tables.py @@ -95,7 +95,7 @@ def from_records(cls, records): Returns: If the list is empty, it will return an empty table. - Otherwise, it will return a table with the labels as the column name, and the corresponding data. + Otherwise, it will return a table with the dictionary's keys as the column name, and the corresponding data. If the dictionaries do not have identical keys, the keys of the first dictionary in the list is used. """ @@ -138,16 +138,7 @@ def read_table(cls, filepath_or_buffer, *args, **vargs): return cls.from_df(df) def _with_columns(self, columns): - """Create a table from a sequence of columns, copying column labels. - - Args: - - columns: A sequence of coloumns with labels - - Returns: - - It returns a table with the input columns containing labels. - """ + """Create a table from a sequence of columns, copying column labels.""" table = type(self)() for label, column in zip(self.labels, columns): self._add_column_and_format(table, label, column)