communication.serializer_plugins.pandas module

(De)serialization logic for pandas objects.

communication.serializer_plugins.pandas.pandas_deserialize_dataframe(obj, opts)[source]

Function for deserializing pandas dataframe

Parameters:
  • obj (bytes | dict[str, Any]) – pandas dataframe to deserialize

  • opts (DeserializerOpts) – options to change the behaviour of the serialization.

Raises:

ImportError – Object was serialized with parquet, but required dependencies for deserialization are missing.

Return type:

DataFrame

Returns:

deserialized dataframe

communication.serializer_plugins.pandas.pandas_deserialize_series(obj, opts)[source]

Function for deserializing pandas series

Parameters:
  • obj (bytes | dict[str, Any]) – pandas series to deserialize

  • opts (DeserializerOpts) – options to change the behaviour of the serialization.

Return type:

Series

Returns:

deserialized series

communication.serializer_plugins.pandas.pandas_deserialize_timestamp(obj, opts)[source]

Function for deserializing pandas timestamp

Parameters:
  • obj (str) – pandas timestamp to deserialize

  • opts (DeserializerOpts) – options to change the behaviour of the serialization.

Return type:

Timestamp

Returns:

deserialized timestamp

communication.serializer_plugins.pandas.pandas_serialize_dataframe(obj, opts)[source]

Function for serializing pandas dataframes

Attempt to use parquet for smaller serialized dataframe, but fallback to dictionaries otherwise.

Parameters:
  • obj (DataFrame) – pandas object to serialize

  • opts (SerializerOpts) – options to change the behaviour of the serialization.

Raises:

ValueError – Column names are not of type <str>.

Return type:

bytes | dict[str, Any]

Returns:

serialized dataframe

communication.serializer_plugins.pandas.pandas_serialize_series(obj, opts)[source]

Function for serializing pandas series

Parameters:
  • obj (Series) – pandas series to serialize

  • opts (SerializerOpts) – options to change the behaviour of the serialization.

Return type:

bytes | dict[str, Any]

Returns:

serialized series

communication.serializer_plugins.pandas.pandas_serialize_timestamp(obj, opts)[source]

Function for serializing pandas timestamp

Parameters:
  • obj (Timestamp) – pandas timestamp to serialize

  • opts (SerializerOpts) – options to change the behaviour of the serialization.

Return type:

str

Returns:

serialized timestamp

communication.serializer_plugins.pandas.register()[source]

Register pandas serializer and deserializer.

Return type:

None