Skip to content

Convert numerics to null-supported Pandas types #679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd
- Enabled n-triples data for `%load` with Neptune Analytics ([PR #1](https://github.com/aws/graph-notebook/pull/671)) ( ([PR #2](https://github.com/aws/graph-notebook/pull/675)))
- Removed unused options from `%load`([Link to PR](https://github.com/aws/graph-notebook/pull/662))
- Made EncryptionKey optional in Neptune CloudFormation template ([Link to PR](https://github.com/aws/graph-notebook/pull/663))
- Fixed unintended type coercion in results table with missing/null values ([Link to PR](https://github.com/aws/graph-notebook/pull/679))

## Release 4.5.1 (July 31, 2024)

Expand Down
6 changes: 3 additions & 3 deletions src/graph_notebook/magics/graph_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def query_type_to_action(query_type):
def oc_results_df(oc_res, oc_res_format: str = None):
rows_and_columns = opencypher_get_rows_and_columns(oc_res, oc_res_format)
if rows_and_columns:
results_df = pd.DataFrame(rows_and_columns['rows'])
results_df = pd.DataFrame(rows_and_columns['rows']).convert_dtypes()
results_df = results_df.astype(str)
results_df = results_df.map(lambda x: encode_html_chars(x))
col_0_value = range(1, len(results_df) + 1)
Expand Down Expand Up @@ -893,7 +893,7 @@ def sparql(self, line='', cell='', local_ns: dict = None):

rows_and_columns = sparql_get_rows_and_columns(results)
if rows_and_columns is not None:
results_df = pd.DataFrame(rows_and_columns['rows'])
results_df = pd.DataFrame(rows_and_columns['rows']).convert_dtypes()
results_df = results_df.astype(str)
results_df = results_df.map(lambda x: encode_html_chars(x))
results_df.insert(0, "#", range(1, len(results_df) + 1))
Expand Down Expand Up @@ -1323,7 +1323,7 @@ def gremlin(self, line, cell, local_ns: dict = None):
query_res_deque.appendleft('x')
query_res = list(query_res_deque)

results_df = pd.DataFrame(query_res)
results_df = pd.DataFrame(query_res).convert_dtypes()
# Checking for created indices instead of the df itself here, as df.empty will still return True when
# only empty maps/lists are present in the data.
if not results_df.index.empty:
Expand Down
Loading