Spotfire and Python Data Type Mapping
To create Python data functions in Spotfire, you need to know how the data types in each application map to each other. This table provides that mapping, including data type mapping to Pandas column dtype, and for mapping columns and tables.
Data type exported from Spotfire | Data type received by Python | Pandas column dtype |
---|---|---|
Integer | int
|
Int32
|
LongInteger | int
|
Int64
|
Real | float
|
float64
|
SingleReal | float
|
float32
|
Currency | decimal.Decimal
|
object
|
Date | datetime.date
|
object
|
DateTime | datetime.datetime
|
object
|
Time | datetime.time
|
object
|
TimeSpan | (not supported) | (not supported) |
Boolean | bool
|
object
|
String | str
|
object
|
Binary | bytes
|
object
|
- Spotfire
columns map in
Python
to Pandas
Series
type. - Spotfire
tables map in
Python
to Pandas
DataFrame
type.
Data type sent by Python | Data type imported into Spotfire |
---|---|
int
|
LongInteger |
float
|
Real |
decimal.Decimal
|
Currency |
datetime.date
|
Date |
datetime.datetime
|
DateTime |
datetime.time
|
Time |
datetime.timedelta
|
TimeSpan |
bool
|
Boolean |
str
|
String |
byte
|
Binary |
- Empty String columns in exported SBDF causes an error
- When you export an SBDF from Python (for example, as output for a
data function), and your output contains an empty column, you can encounter the
following error:
spotfire.sbdf.SBDFError: cannot determine type for column 'EmptyString'; all values are missing
This error occurs because the Spotfire data function environment cannot determine the proper Spotfire type to export the data as if all values in the column are missing (in other words, Python's
None
, NumPy'snan
, or Panda'sNA
orNaT
values).To resolve this issue, edit your data function to use the helper function
set_spotfire_types
.Example
import pandas as pd import spotfire df = pd.DataFrame(inp) spotfire.set_spotfire_types(df, {'EmptyString': 'String'})