Skip to content

Pandas Dataframe index not saved #81

Description

@tibco-slolla

spotfire.sbdf.export_data does not appear to save pandas data frame index data to SBDF files. Perhaps we could save the index information to an extra column and put in metadata to indicate that it is index information.

Code to reproduce issue:

import os
import tempfile
import pandas as pd
import spotfire
import pandas.testing as pdt


TGT_DIR = tempfile.gettempdir()
FILE_NAME = "data.sbdf"
file_path = os.path.join(TGT_DIR, FILE_NAME)

col_1 = list(range(1, 11))
col_2 = [i * i for i in col_1]

df_1 = pd.DataFrame({"col_1": col_1, "col_2": col_2})
df_1.index = [
    "a", "b", "c", "d", "e",
    "f", "g", "h", "i", "j"
]

print("--- df_1 ---")
print(df_1)

spotfire.sbdf.export_data(
    df_1,
    os.path.join(TGT_DIR, file_path)
)

df_2 = spotfire.sbdf.import_data(
    os.path.join(TGT_DIR, file_path)
)

print("--- df_2 ---")
print(df_2)

pdt.assert_frame_equal(df_1, df_2)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions