Skip to content

Commit 873abff

Browse files
authored
Convert numerics to null-supported Pandas types (#679)
* Convert numerics to null-supported Pandas types * update changelog
1 parent 187b295 commit 873abff

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd
1111
- 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)))
1212
- Removed unused options from `%load`([Link to PR](https://github.com/aws/graph-notebook/pull/662))
1313
- Made EncryptionKey optional in Neptune CloudFormation template ([Link to PR](https://github.com/aws/graph-notebook/pull/663))
14+
- Fixed unintended type coercion in results table with missing/null values ([Link to PR](https://github.com/aws/graph-notebook/pull/679))
1415

1516
## Release 4.5.1 (July 31, 2024)
1617

src/graph_notebook/magics/graph_magic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def query_type_to_action(query_type):
241241
def oc_results_df(oc_res, oc_res_format: str = None):
242242
rows_and_columns = opencypher_get_rows_and_columns(oc_res, oc_res_format)
243243
if rows_and_columns:
244-
results_df = pd.DataFrame(rows_and_columns['rows'])
244+
results_df = pd.DataFrame(rows_and_columns['rows']).convert_dtypes()
245245
results_df = results_df.astype(str)
246246
results_df = results_df.map(lambda x: encode_html_chars(x))
247247
col_0_value = range(1, len(results_df) + 1)
@@ -893,7 +893,7 @@ def sparql(self, line='', cell='', local_ns: dict = None):
893893

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

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

0 commit comments

Comments
 (0)