Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-dfs
csst-dfs-api
Commits
4aee301e
Commit
4aee301e
authored
Jul 04, 2023
by
Wei Shoulin
Browse files
to_table with pandas
parent
48f313ef
Changes
1
Show whitespace changes
Inline
Side-by-side
csst_dfs_api/common/utils.py
View file @
4aee301e
...
...
@@ -103,17 +103,17 @@ def tuple_fields_dtypes(rec: tuple):
dtypes
=
tuple
(
dtypes
)
return
dtypes
def
to_table
(
query_result
):
if
not
query_result
.
success
or
not
query_result
.
data
:
return
Table
()
fields
=
query_result
[
'columns'
]
dtypes
=
tuple_fields_dtypes
(
query_result
.
data
[
0
])
t
=
Table
(
names
=
fields
,
dtype
=
dtypes
,
rows
=
query_result
.
data
)
t
.
meta
[
'columns'
]
=
fields
t
.
meta
[
'total'
]
=
query_result
[
'totalCount'
]
return
t
#
def to_table(query_result):
#
if not query_result.success or not query_result.data:
#
return Table()
#
fields = query_result['columns']
#
dtypes = tuple_fields_dtypes(query_result.data[0])
#
t = Table(names = fields, dtype = dtypes, rows = query_result.data)
#
t.meta['columns'] = fields
#
t.meta['total'] = query_result['totalCount']
#
return t
def
to_table
_v2
(
query_result
):
def
to_table
(
query_result
):
if
not
query_result
.
success
or
not
query_result
.
data
:
return
Table
()
df
=
pd
.
DataFrame
(
data
=
query_result
.
data
,
columns
=
query_result
[
'columns'
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment