data_algebra/util.py
def pandas_to_example_str(obj, *, local_data_model=None) -> str:
    """
    Convert data frame to a Python source code string.

    :param obj: data frame to convert.
    :param local_data_model: data model to use.
    :return: Python source code representation of obj.
    """
    if local_data_model is None:
        local_data_model = data_algebra.default_data_model
    pd_module_name = local_data_model.presentation_model_name
    if not local_data_model.is_appropriate_data_instance(obj):
        raise TypeError("Expect obj to be local_data_model.pd.DataFrame")
    obj = obj.reset_index(drop=True, inplace=False)
    nrow = obj.shape[0]
    pandas_string = pd_module_name + ".DataFrame({"
    for k in obj.columns:
        col = obj[k]
        nulls = local_data_model.bad_column_positions(col)
        cells = ["None" if nulls[i] else col[i].__repr__() for i in range(nrow)]
        pandas_string = (
            pandas_string + "\n    " + k.__repr__() + ": [" + ", ".join(cells) + "],"
        )
    pandas_string = pandas_string + "\n    })"
    return pandas_string

    Convert data frame to a Python source code string.

    :param obj: data frame to convert.
    :param local_data_model: data model to use.
    :return: Python source code representation of obj.
    
Convert data frame to a Python source code string.
Convert data frame to a Python source code string .
def pandas_to_example_str(obj, *, local_data_model=None) -> str:
    if local_data_model is None:
        local_data_model = data_algebra.default_data_model
    pd_module_name = local_data_model.presentation_model_name
    if not local_data_model.is_appropriate_data_instance(obj):
        raise TypeError("Expect obj to be local_data_model.pd.DataFrame")
    obj = obj.reset_index(drop=True, inplace=False)
    nrow = obj.shape[0]
    pandas_string = pd_module_name + ".DataFrame({"
    for k in obj.columns:
        col = obj[k]
        nulls = local_data_model.bad_column_positions(col)
        cells = ["None" if nulls[i] else col[i].__repr__() for i in range(nrow)]
        pandas_string = (
            pandas_string + "\n    " + k.__repr__() + ": [" + ", ".join(cells) + "],"
        )
    pandas_string = pandas_string + "\n    })"
    return pandas_string
def pandas_to_example_str ( obj , * , local_data_model = None ) -> str : if local_data_model is None : local_data_model = data_algebra . default_data_model pd_module_name = local_data_model . presentation_model_name if not local_data_model . is_appropriate_data_instance ( obj ) : raise TypeError ( "Expect obj to be local_data_model.pd.DataFrame" ) obj = obj . reset_index ( drop = True , inplace = False ) nrow = obj . shape [ 0 ] pandas_string = pd_module_name + ".DataFrame({" for k in obj . columns : col = obj [ k ] nulls = local_data_model . bad_column_positions ( col ) cells = [ "None" if nulls [ i ] else col [ i ] . __repr__ ( ) for i in range ( nrow ) ] pandas_string = ( pandas_string + "\n    " + k . __repr__ ( ) + ": [" + ", " . join ( cells ) + "]," ) pandas_string = pandas_string + "\n    })" return pandas_string
Convert data frame to a Python source code string.
Convert data frame to a Python source code string .
"""
    Convert data frame to a Python source code string.

    :param obj: data frame to convert.
    :param local_data_model: data model to use.
    :return: Python source code representation of obj.
    """
Python source code representation of obj.
Python source code representation of obj .
obj
data frame to convert.
data frame to convert .
local_data_model
data model to use.
data model to use .