Skip to content

Commit 1fcf827

Browse files
committed
convert to df from_dict
1 parent 963b888 commit 1fcf827

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ExtractTable/common.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Preprocess the output received from server and interface as a final result to the client
33
"""
4-
import json
54
import os
65
import tempfile
76
import warnings
@@ -31,10 +30,10 @@ def _converter(self, fmt: str, index: bool = False) -> list:
3130
:param index: row index consideration in the output
3231
:return: list of tables from converted into the requested output format
3332
"""
34-
dfs = [pd.read_json(json.dumps(table["TableJson"]).T) for table in self.data["Tables"]]
33+
dfs = [pd.DataFrame.from_dict(table["TableJson"]).T for table in self.data["Tables"]]
3534
if fmt in ("df", "dataframe"):
3635
return dfs
37-
if fmt == "dict":
36+
elif fmt == "dict":
3837
return [df.to_dict() for df in dfs]
3938
elif fmt == "csv":
4039
save_folder = tempfile.mkdtemp()

0 commit comments

Comments
 (0)