@@ -1747,6 +1747,8 @@ def virtualfile_to_dataset(
17471747 vfname : str ,
17481748 output_type : Literal ["pandas" , "numpy" , "file" ] = "pandas" ,
17491749 column_names : list [str ] | None = None ,
1750+ dtype : type | dict [str , type ] | None = None ,
1751+ index_col : str | int | None = None ,
17501752 ) -> pd .DataFrame | np .ndarray | None :
17511753 """
17521754 Output a tabular dataset stored in a virtual file to a different format.
@@ -1766,6 +1768,11 @@ def virtualfile_to_dataset(
17661768 - ``"file"`` means the result was saved to a file and will return ``None``.
17671769 column_names
17681770 The column names for the :class:`pandas.DataFrame` output.
1771+ dtype
1772+ Data type for the columns of the :class:`pandas.DataFrame` output. Can be a
1773+ single type for all columns or a dictionary mapping column names to types.
1774+ index_col
1775+ Column to set as the index of the :class:`pandas.DataFrame` output.
17691776
17701777 Returns
17711778 -------
@@ -1854,13 +1861,13 @@ def virtualfile_to_dataset(
18541861 return None
18551862
18561863 # Read the virtual file as a GMT dataset and convert to pandas.DataFrame
1857- result = self .read_virtualfile (vfname , kind = "dataset" ).contents .to_dataframe ()
1864+ result = self .read_virtualfile (vfname , kind = "dataset" ).contents .to_dataframe (
1865+ column_names = column_names ,
1866+ dtype = dtype ,
1867+ index_col = index_col ,
1868+ )
18581869 if output_type == "numpy" : # numpy.ndarray output
18591870 return result .to_numpy ()
1860-
1861- # Assign column names
1862- if column_names is not None :
1863- result .columns = column_names
18641871 return result # pandas.DataFrame output
18651872
18661873 def extract_region (self ):
0 commit comments