Skip to content

Commit

Permalink
Merge pull request #58 from wey-gu/table_render_opt
Browse files Browse the repository at this point in the history
opt: better dataframe rendering
  • Loading branch information
wey-gu authored May 22, 2024
2 parents e41b1bf + 7164d4c commit 42c6488
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ examples/*.html

# mkdocs
.cache

# python
.venv
11 changes: 10 additions & 1 deletion ngql/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,22 @@ def _stylized(self, result):
except ImportError:
raise ImportError("Please install pandas to use STYLE_PANDAS")

pd.set_option("display.max_columns", None)
pd.set_option("display.max_colwidth", None)
pd.set_option("display.max_rows", 300)
pd.set_option("display.expand_frame_repr", False)

columns = result.keys()
d: Dict[str, list] = {}
for col_num in range(result.col_size()):
col_name = columns[col_num]
col_list = result.column_values(col_name)
d[col_name] = [x.cast() for x in col_list]
return pd.DataFrame(d)
df = pd.DataFrame(d)
df.style.set_table_styles(
[{"selector": "table", "props": [("overflow-x", "scroll")]}]
)
return df
elif self.ngql_result_style == STYLE_RAW:
return result
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Jinja2
nebula3-python>=3.5.1
nebula3-python>=3.8.0
pandas
tqdm
pyvis
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
python_requires=">=3.6",
install_requires=[
"Jinja2",
"nebula3-python>=3.5.1",
"nebula3-python>=3.8.0",
"pandas",
"tqdm",
"pyvis",
Expand Down
2 changes: 1 addition & 1 deletion setup_ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
python_requires=">=3.6",
install_requires=[
"Jinja2",
"nebula3-python>=3.5.1",
"nebula3-python>=3.8.0",
"pandas",
"tqdm",
"pyvis",
Expand Down

0 comments on commit 42c6488

Please sign in to comment.