Skip to content

get_table_data(): "False" string incorrectly converts to True (bool conversion pitfall) #200

@DavidNeedsHiking

Description

@DavidNeedsHiking

Summary

When reading DataFrame data via get_table_data() or query_table_data(), boolean values are returned as strings ("True"/"False"). Converting these back to Python booleans using bool() or pd.Series.astype(bool) incorrectly treats "False" as True because any non-empty string is truthy in Python.

Steps to Reproduce

from nisystemlink.clients.dataframe import DataFrameClient

client = DataFrameClient()
result = client.get_table_data(table_id)

# result.frame.data contains: [["1", "False"], ["2", "True"]]
# Attempting to convert:
bool("False")  # Returns True! (incorrect)

Expected Behavior

Boolean string values should convert correctly: "False" → False, "True" → True

Suggested Fix

Add a helper method or conversion utility that uses explicit mapping instead of bool():

_bool_map = {'true': True, '1': True, 'false': False, '0': False}
series.str.strip().str.lower().map(_bool_map)
  1. Short-term fix: Add a utility function like frame_to_pandas(result.frame, dtypes={...}) that handles boolean (and other type) conversions safely

  2. Long-term fix: Return Arrow/binary data for read operations too, matching the write format — eliminating the JSON string conversion entirely

Environment

Python 3.x
nisystemlink-clients (latest)

Related

This asymmetry exists because writes use Arrow binary format (types preserved) while reads use JSON (all strings). A frame_to_pandas() helper in the SDK would save users from this pitfall.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions