pbspark/_proto.py
def df_to_protobuf(
        self,
        df: DataFrame,
        message_type: t.Type[Message],
        options: t.Optional[dict] = None,
        expanded: bool = False,
    ) -> DataFrame:
        """Encode data in a dataframe to protobuf as column `value`.

        If `expanded`, the passed dataframe columns will be packed into a struct before
        converting. Otherwise it is assumed that the dataframe passed is a single column
        of data already packed into a struct.

        Returns a dataframe with a single column named `value` containing encoded data.
        """
        if expanded:
            df_struct = df.select(
                struct([df[c] for c in df.columns]).alias("value")  # type: ignore[arg-type]
            )
        else:
            df_struct = df.select(col(df.columns[0]).alias("value"))
        df_encoded = df_struct.select(
            self.to_protobuf(df_struct.value, message_type, options).alias("value")
        )
        return df_encoded
Encode data in a dataframe to protobuf as column `value`.

        If `expanded`, the passed dataframe columns will be packed into a struct before
        converting. Otherwise it is assumed that the dataframe passed is a single column
        of data already packed into a struct.

        Returns a dataframe with a single column named `value` containing encoded data.
        
Encode data in a dataframe to protobuf as column `value`.
If `expanded`, the passed dataframe columns will be packed into a struct before
converting. Otherwise it is assumed that the dataframe passed is a single column
of data already packed into a struct.

Returns a dataframe with a single column named `value` containing encoded data.
Encode data in a dataframe to protobuf as column ` value ` . If ` expanded ` the passed dataframe columns will be packed into a struct before converting . Otherwise it is assumed that the dataframe passed is a single column of data already packed into a struct . Returns a dataframe with a single column named ` value ` containing encoded data .
def df_to_protobuf(
        self,
        df: DataFrame,
        message_type: t.Type[Message],
        options: t.Optional[dict] = None,
        expanded: bool = False,
    ) -> DataFrame:
        if expanded:
            df_struct = df.select(
                struct([df[c] for c in df.columns]).alias("value")  
            )
        else:
            df_struct = df.select(col(df.columns[0]).alias("value"))
        df_encoded = df_struct.select(
            self.to_protobuf(df_struct.value, message_type, options).alias("value")
        )
        return df_encoded
def df_to_protobuf ( self , df : DataFrame , message_type : t . Type [ Message ] , options : t . Optional [ dict ] = None , expanded : bool = False , ) -> DataFrame : if expanded : df_struct = df . select ( struct ( [ df [ c ] for c in df . columns ] ) . alias ( "value" ) ) else : df_struct = df . select ( col ( df . columns [ 0 ] ) . alias ( "value" ) ) df_encoded = df_struct . select ( self . to_protobuf ( df_struct . value , message_type , options ) . alias ( "value" ) ) return df_encoded
Encode data in a dataframe to protobuf as column `value`.
Encode data in a dataframe to protobuf as column ` value ` .
"""Encode data in a dataframe to protobuf as column `value`.

        If `expanded`, the passed dataframe columns will be packed into a struct before
        converting. Otherwise it is assumed that the dataframe passed is a single column
        of data already packed into a struct.

        Returns a dataframe with a single column named `value` containing encoded data.
        """ # type: ignore[arg-type]
self
df
DataFrame
message_type
t.Type[Message]
options
t.Optional[dict]
expanded
bool