Skip to content

ENH: Add to_tf_dataset method to convert Pandas dataframe to TensorFlow dataset #48524

Closed
@jamiecash

Description

@jamiecash

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

I wish I could use pandas to create TensorFlow datasets

Feature Description

Add a new method to_tf_dataset to DataFrame, specifying columns to use as features and labels.

def to_tf_dataset(feature_columns: list[str], label_column: str) -> tf.data.Dataset:
"""
Params:
feature_columns: list[str]: A list of columns to use as features for the dataset
label_column: The column to use as the label for the dataset. Numeric columns will be used as is. Non numeric columns will be converted to pd.Categorical
"""

Alternative Solutions

Manual conversion using tf.data.Dataset.from_tensor_slices

Additional Context

No response

Metadata

Metadata

Assignees

Labels

EnhancementIO DataIO issues that don't fit into a more specific labelNeeds DiscussionRequires discussion from core team before further action

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions