Skip to content

Commit a0d7ed0

Browse files
committed
Merge branch 'main' into clib/return_table
2 parents 7f4f6b1 + a5d8b14 commit a0d7ed0

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

pygmt/clib/session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ def virtualfile_out(
16211621
Create a virtual file or an actual file for storing output data.
16221622
16231623
If ``fname`` is not given, a virtual file will be created to store the output
1624-
data into a GMT data container and the function yields the name of the virutal
1624+
data into a GMT data container and the function yields the name of the virtual
16251625
file. Otherwise, the output data will be written into the specified file and the
16261626
function simply yields the actual file name.
16271627

pygmt/datatypes/dataset.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def to_dataframe(self) -> pd.DataFrame:
180180
1 4.0 5.0 6.0 TEXT4 TEXT567
181181
2 7.0 8.0 9.0 TEXT8 TEXT90
182182
3 10.0 11.0 12.0 TEXT123 TEXT456789
183+
>>> df.dtypes.to_list()
184+
[dtype('float64'), dtype('float64'), dtype('float64'), string[python]]
183185
"""
184186
# Deal with numeric columns
185187
vectors = []
@@ -192,7 +194,7 @@ def to_dataframe(self) -> pd.DataFrame:
192194
colvector.append(
193195
np.ctypeslib.as_array(dseg.data[icol], shape=(dseg.n_rows,))
194196
)
195-
vectors.append(np.concatenate(colvector))
197+
vectors.append(pd.Series(data=np.concatenate(colvector)))
196198

197199
# Deal with trailing text column
198200
textvector = []
@@ -203,16 +205,9 @@ def to_dataframe(self) -> pd.DataFrame:
203205
if dseg.text:
204206
textvector.extend(dseg.text[: dseg.n_rows])
205207
if textvector:
206-
vectors.append(np.char.decode(textvector))
207-
208-
df = pd.concat([pd.Series(v) for v in vectors], axis=1)
209-
210-
# convert text data from object dtype to string dtype
211-
if textvector:
212-
df = df.convert_dtypes(
213-
convert_string=True,
214-
convert_integer=False,
215-
convert_floating=False,
216-
convert_boolean=False,
208+
vectors.append(
209+
pd.Series(data=np.char.decode(textvector), dtype=pd.StringDtype())
217210
)
211+
212+
df = pd.concat(objs=vectors, axis=1)
218213
return df

0 commit comments

Comments
 (0)