Terality Docs
  • What is Terality?
  • Documentation
    • Quickstart
      • Setup
      • Tutorial
      • Next steps
    • User guide
      • Supported configurations
      • User dashboard
      • Importing and exporting data
        • Reading/writing to storage
        • Reading from multiple files
        • Writing to multiple files
        • Storage services
        • Data formats
        • From/to pandas
      • .apply() and passing callables
      • Caching
      • Best practices and anti-patterns
      • Upgrading your client version
      • Client configuration (CLI)
      • Support for external packages
      • Advanced topics
        • Data mutability and ownership: Terality vs pandas
    • API Reference
      • Conversion from/to pandas
      • Write to multiple files
    • Deploy Terality in your own AWS account
    • Releases
  • FAQ
    • Differences with
      • Terality and Pandas
      • Terality vs Spark
      • Terality vs Dask
    • Pricing
    • Security
    • Support & contact
    • Common setup issues
Powered by GitBook
On this page

Was this helpful?

  1. Documentation
  2. API Reference

Conversion from/to pandas

Each Terality structure provides two methods that allow you to easily convert pandas objects into terality structures and conversely.

Using from_pandas / from_ndarray methods, all the data will be retrieved in your RAM. If the object size is too important, you may run into a MemoryError.

DataFrame:

@classmethod 
terality.DataFrame.from_pandas(df: pandas.DataFrame) -> terality.DataFrame
terality.DataFrame.to_pandas() -> pandas.DataFrame

Series:

@classmethod 
terality.Series.from_pandas(series: pandas.Series) -> terality.Series
terality.Series.to_pandas() -> pandas.Series

Index:

@classmethod 
terality.Index.from_pandas(index: pandas.Index) -> terality.Index
terality.Index.to_pandas() -> pandas.Index

NDArray:

@classmethod 
terality.NDArray.from_ndarray(ndarray: numpy.ndarray) -> terality.NDArray
terality.NDArray.to_ndarray() -> numpy.ndarray

terality.NDArray is meant to be used within pandas methods arguments, the numpy API is not supported by terality. Only 1D arrays are currently implemented.

Using these methods, you can easily make roundtrips between pandas and Terality structures with small amounts of data.

import pandas as pd
import terality as te

pdf = pd.DataFrame(range(100))
tdf = te.DataFrame.from_pandas(pdf)
pdf_round_trip = tdf.to_pandas()
PreviousAPI ReferenceNextWrite to multiple files

Last updated 3 years ago

Was this helpful?