elphick.pandera_utils.pandera_utils.order_columns_to_match_schema
- elphick.pandera_utils.pandera_utils.order_columns_to_match_schema(df, schema)[source]
Order DataFrame columns to match the schema order if coerce and metadata[‘order_columns’] are true.
Columns not specified in the schema will be retained at the end of the DataFrame. :type df:
DataFrame
:param df: The DataFrame to reorder. :type schema:DataFrameSchema
:param schema: The Pandera DataFrameSchema defining the desired column order.- Return type:
DataFrame
- Returns:
A DataFrame with columns reordered to match the schema, retaining extra columns at the end.