From/to pandas

Blob

Building a Terality DataFrame from a pandas DataFrame

If you have a pandas DataFrame or Series, you can import it into Terality with the from_pandas method. You can also convert to Terality DataFrame to a pandas DataFrame with to_pandas.

This is useful when you want to import data with a format not yet supported by Terality: read it with pandas first, then call from_pandas.

import terality as te
import pandas as pd

df_pd = pd.DataFrame({"a": ["he", "llo", "wor", "ld", "!"]})
df_te = te.DataFrame.from_pandas(df_pd)

Retrieving a Terality data structure as a pandas data structure in memory

If you want to continue working on your data in Python, for example doing Machine Learning, you can export back the Terality DataFrame to a pandas DataFrame locally and start using your favorite ML framework.

For this option, you must ensure that the DataFrame is small enough to fit in memory. You're leaving the world of Terality's unlimited memory!

# Convert back the Terality DataFrame to a pandas DataFrame
df_pd_2 = df_te.to_pandas()

# we can check that we recovered our original pandas DataFrame
pd.assert(df_pd, df_pd2)

Last updated

Was this helpful?