-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Given the following script:
from spotfire import sbdf
import pandas as pd
T1 = pd.Series([1, 2, 3, 4, 5])
T2 = pd.Series([6, 7, 8, 9, 10])
T3 = pd.Series([11, 12, 13, 14, 15])
TX = pd.concat([T1, T2, T3])
sbdf.export_data(TX, "C:/tmp/out.sbdf")Output:
Traceback (most recent call last):
File "repro.py", line 9, in <module>
sbdf.export_data(TX, "C:/tmp/out.sbdf")
File "spotfire\\sbdf.pyx", line 1780, in spotfire.sbdf.export_data
File "spotfire\\sbdf.pyx", line 995, in spotfire.sbdf._export_obj_series
File "spotfire\\sbdf.pyx", line 1172, in spotfire.sbdf._export_infer_invalids
File "C:\src\github\spotfire-python\venv\w312\Lib\site-packages\pandas\core\generic.py", line 1577, in __nonzero__
raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
This is a result of the concatenation operation. The Series' index is Index([0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4], dtype='int64'), so requesting x[0] turns what we were expecting to be an array access operation into a subsetting operation. Thus, our truthyness check fails out because it's working on the wrong data type.
We should use Series.iloc instead of direct subsetting to fix the issue.
As a workaround, it is recommended to use the ignore_index=True parameter when doing the concatenation to avoid creating the duplicative series index.
Metadata
Metadata
Assignees
Labels
No labels