Skip to content

Commit 193bd05

Browse files
committed
Improve docstrings
1 parent d376a74 commit 193bd05

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pygmt/clib/session.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ def read_virtualfile(
17411741
def return_table(
17421742
self,
17431743
output_type: Literal["pandas", "numpy", "file"],
1744-
vfile: str,
1744+
vfile: str | None = None,
17451745
column_names: list[str] | None = None,
17461746
) -> pd.DataFrame | np.ndarray | None:
17471747
"""
@@ -1750,16 +1750,21 @@ def return_table(
17501750
Parameters
17511751
----------
17521752
output_type
1753-
The output type. Valid values are ``"pandas"``, ``"numpy"``, or ``"file"``.
1753+
Desired output type of the result data.
1754+
1755+
- ``"pandas"`` will return a :class:`pandas.DataFrame` object.
1756+
- ``"numpy"`` will return a :class:`numpy.ndarray` object.
1757+
- ``"file"`` means the result was saved to a file and will return ``None``.
17541758
vfile
1755-
The virtual file name.
1759+
The virtual file name that stores the result data. Required for ``"pandas"``
1760+
and ``"numpy"`` output type.
17561761
column_names
17571762
The column names for the :class:`pandas.DataFrame` output.
17581763
17591764
Returns
17601765
-------
1761-
:class:`pandas.DataFrame` or :class:`numpy.ndarray` or None
1762-
The output table. If ``output_type`` is ``"file"``, returns ``None``.
1766+
table
1767+
The output table. If ``output_type="file"`` returns ``None``.
17631768
17641769
Examples
17651770
--------
@@ -1835,16 +1840,16 @@ def return_table(
18351840
"""
18361841
if output_type == "file": # Already written to file, so return None
18371842
return None
1843+
18381844
# Read the virtual file as a GMT dataset and convert to pandas.DataFrame
18391845
result = self.read_virtualfile(vfile, kind="dataset").contents.to_dataframe()
1846+
if output_type == "numpy": # numpy.ndarray output
1847+
return result.to_numpy()
1848+
18401849
# Assign column names
18411850
if column_names is not None:
18421851
result.columns = column_names
1843-
# Pandas.DataFrame output
1844-
if output_type == "pandas":
1845-
return result
1846-
# NumPy.ndarray output
1847-
return result.to_numpy()
1852+
return result # pandas.DataFrame output
18481853

18491854
def extract_region(self):
18501855
"""

0 commit comments

Comments
 (0)