Module pyfx.internal.pandasutil
Utility functions to convert pandas DataFrames to avro and pricefx FieldCollections.
Contains also schema type conversion functions - from pandas to avro - from pandas to pricefx FieldCollections.
Functions
def to_avro_type(column: pandas.core.series.Series) ‑> Union[str, Dict[str, Any], ForwardRef(None)]
-
Returns the avro type declaration corresponding to the given pandas Series data.
Return None if the given numpy type is not supported.
Args
column
- the column data as pd.Series
def to_field_collection_spec(dataframe: pandas.core.frame.DataFrame, dimensions: Optional[List[str]] = None, on_unsupported_type: str = 'error', inplace: bool = False, column_labels: Optional[Dict[str, str]] = None) ‑> Tuple[List[Dict[str, Any]], pandas.core.frame.DataFrame]
-
Returns the pricefx field collection spec and the corresponding DataFrame.
Args
dataframe
- the dataframe to push
dimensions
- columns that should be used as dimension (optional, default: None)
on_unsupported_type
- define the behavior when encontering a dataframe column containing an incompatible type (optional, default: "error"):
- "error" (default value) raises an error
- "drop" will drop the column
- "coerce" will try to convert this column to strings
inplace
- do the required data prep operations in place (will mutate the source dataframe ; optional, default: False)
column_labels
- a dictionary associating dataframe column (including index) name to its desired label (optional, default: None).
def to_pricefx_type(column: pandas.core.series.Series) ‑> Optional[str]
-
Returns the pricefx column type corresponding to the given pandas Series data.
Return None if the given numpy type is not supported.
Args
column
- the column data as pd.Series