spotfiresoftware / spotfire-python

Package for Building Python Extensions to Spotfire®
Other
18 stars 6 forks source link

SBDF exporting does not handle "Float64" column dtype (note capitalization) #25

Closed bbassett-tibco closed 2 years ago

bbassett-tibco commented 2 years ago

The following code snippet (which should work without problems):

import pandas as pd
from spotfire import sbdf
x = pd.Series([1.5, None], dtype="Float64")
sbdf.export_data(x, "out1.sbdf")

generates this exception:

Traceback (most recent call last):
  File "/usr/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "spotfire-python/spotfire/sbdf.py", line 162, in export_data
    columns, column_names, column_types, table_metadata, column_metadata = _export_columnize_data(obj,
  File "spotfire-python/spotfire/sbdf.py", line 224, in _export_columnize_data
    column_types = {series_name: _ValueTypeId.infer_from_dtype(obj, series_description)}
  File "spotfire-python/spotfire/sbdf.py", line 1034, in infer_from_dtype
    raise SBDFError(f"unknown dtype '{dtype}' in {series_description}")
spotfire.sbdf.SBDFError: unknown dtype 'Float64' in series

It works when the export is converted to the "float64" dtype:

sbdf.export_data(x.astype("float64"), "out2.sbdf")

Fix things so the capital-F "Float64" (and "Float32") dtypes export without the conversion.