Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def export_dataframe_tableau(dataframe, filename="dataframe.hyper"):
"""
Export a Pandas dataframe to a Tableau file.
:param dataframe: Pandas dataframe.
:param filename: Python string.
:return: None.
"""
global result
import pantab
# TODO: Fix ModuleNotFoundError: No module named 'tableauhyperapi'
result = dataframe.to_json(orient='split')
pantab.frame_to_hyper(dataframe, filename)
with open(filename, "rb") as binary_file:
file_bin = binary_file.read()
assert file_bin is not None
result = file_bin
resultMetadata.put("file.extension", ".hyper")
resultMetadata.put("file.name", filename)
resultMetadata.put("content.type", "application/octet-stream")
{
"int16": np.int16,
"int32": np.int32,
"int64": np.int64,
"float32": np.float32,
"float64": np.float64,
"bool": np.bool,
"datetime64": "datetime64[ns]",
"datetime64_utc": "datetime64[ns, UTC]",
"timedelta64": "timedelta64[ns]",
"object": "object",
}
)
path = "test.hyper"
pantab.frame_to_hyper(df, path, table="test")
return df
def peakmem_write_frame(self):
pantab.frame_to_hyper(self.df, "dummy.hyper", table="dummy")
def time_write_frame(self, df):
pantab.frame_to_hyper(df, "dummy.hyper", table="dummy")
def time_write_frame(self):
pantab.frame_to_hyper(self.df, "dummy.hyper", table="dummy")
def setup_cache(self):
df = pd.DataFrame(np.ones((10_000_000, 1)), columns=["a"])
path = "test.hyper"
pantab.frame_to_hyper(df, path, table="test")