Commit 4aee301e authored by Wei Shoulin's avatar Wei Shoulin
Browse files

to_table with pandas

parent 48f313ef
...@@ -103,17 +103,17 @@ def tuple_fields_dtypes(rec: tuple): ...@@ -103,17 +103,17 @@ def tuple_fields_dtypes(rec: tuple):
dtypes = tuple(dtypes) dtypes = tuple(dtypes)
return dtypes return dtypes
def to_table(query_result): # def to_table(query_result):
if not query_result.success or not query_result.data: # if not query_result.success or not query_result.data:
return Table() # return Table()
fields = query_result['columns'] # fields = query_result['columns']
dtypes = tuple_fields_dtypes(query_result.data[0]) # dtypes = tuple_fields_dtypes(query_result.data[0])
t = Table(names = fields, dtype = dtypes, rows = query_result.data) # t = Table(names = fields, dtype = dtypes, rows = query_result.data)
t.meta['columns'] = fields # t.meta['columns'] = fields
t.meta['total'] = query_result['totalCount'] # t.meta['total'] = query_result['totalCount']
return t # return t
def to_table_v2(query_result): def to_table(query_result):
if not query_result.success or not query_result.data: if not query_result.success or not query_result.data:
return Table() return Table()
df = pd.DataFrame(data = query_result.data, columns = query_result['columns']) df = pd.DataFrame(data = query_result.data, columns = query_result['columns'])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment