Search…
Platform tools
This page is a collection of methods used to save and retrieve custom user data inside the SigTech platform.
The following command imports the Python module:
1
from sigtech import platform_tools
Copied!

Saving DataFrames and series

Pandas DataFrames and series can be saved to a file in a user's designated AWS S3 bucket and accessed later using the same workspace.
The following code block demonstrates how to save a Pandas DataFrame into a .csv file and store it in the AWS S3 bucket:
1
from sigtech import platform_tools as pt
2
import pandas as pd
3
4
hist = pd.DataFrame({'data': [1, 2, 3, 4]})
5
pt.save_raw(hist, 'signal_data.csv')
Copied!
Once saved, the following code loads the file.
1
from sigtech import platform_tools as pt
2
hist = pt.get_raw('signal_data.csv')
Copied!

Saving other file formats

Other file types can be saved to S3 using the save_file function and retrieved using the open_file function within Platform Tools.
Example: a NumPy series can be saved in bytes to a file-like object and parsed with the save_file function:
1
import io
2
import numpy as np
3
from sigtech import platform_tools as pt
4
5
results = np.array([])
6
file_obj = io.BytesIO()
7
np.save(file_obj, results, allow_pickle = True)
8
9
# We place the pointer back at the beginning of the file-like object
10
file_obj.seek(0)
11
pt.save_file(file_obj, f'results')
Copied!
The file can later be retrieved with the open_file function, which works similarly to Python's built-in open function:
1
import numpy as np
2
from sigtech import platform_tools as pt
3
4
with pt.open_file(f'results') as f:
5
results = np.load(f, allow_pickle=True)
Copied!

Uploading in the workspace

Data can also be uploaded in the Custom Data pathway in your workspace.
To upload a file, click Custom Data in the workspace-and-collaboration menu:
Upload your own custom data via the workspace
The Custom Data screen is displayed. Follow the onscreen instructions to upload your file.
Once uploaded, the open_file function can also be used to access this data. In the following example, the file name "dummy_data.csv" is adopted.
Amend this file name to match the name of the file you have uploaded to run the code block:
1
from sigtech import platform_tools
2
import pandas as pd
3
4
# assuming the file name is dummy_data.csv
5
df = pd.read_csv(platform_tools.open_file("dummy_data.csv"))
Copied!

Data Ingestion API

The functions get_dataset and get_dataset_file can be used to retrieve datasets and individual files previously uploaded using the data ingestion API.
Results are returned as a Pandas DataFrame. In the following example '<id>' is used as a shorthand for explanatory purposes.
Learn more: Data Ingestion API
1
from sigtech import platform_tools as pt
2
3
dataset_id = '<id>'
4
file_id = '<id>'
5
6
full_dataset = pt.get_dataset(dataset_id)
7
individual_file_df = pt.get_dataset_file(dataset_id, file_id)
Copied!