Skip to content

df2ds

airt.keras.experiments.df2ds(df: pd.DataFrame) -> tf.data.Dataset ยค

Converts DataFrame to Dataset

Parameters:

Name Type Description Default
df pd.DataFrame

input DataFrame

required

Returns:

Type Description
tf.data.Dataset

dataset

Source code in airt/keras/experiments.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
def df2ds(df: pd.DataFrame) -> tf.data.Dataset:
    """Converts DataFrame to Dataset

    Args:
        df: input DataFrame

    Returns:
        dataset
    """
    x = df.to_dict("list")
    y = x.pop("ground_truth")

    ds = tf.data.Dataset.from_tensor_slices((x, y))

    return ds