Load data to pandas
Tensorflow Datasets
import tensorflow_datasets as tfds
MAXIMUM_DATASET_SIZE = 10000 # set up the maximum number of lines in your sample
# tensorflow_ds is a shuffled Tensorflow Dataset
pandas_df = tfds.as_dataframe(tensorflow_ds.take(MAXIMUM_DATASET_SIZE))Pytorch Datapipes
import pandas as pd
from torchdata.datapipes.iter import HttpReader
MAXIMUM_DATASET_SIZE = 10000 # set up the maximum number of lines in your sample
# Load data to Pytorch Datapipe
URL = "https://raw.githubusercontent.com/mhjabreel/CharCnn_Keras/master/data/ag_news_csv/train.csv"
ag_news_train = HttpReader([URL]).parse_csv().map(lambda t: (int(t[0]), " ".join(t[1:])))
# Shuffle and sample data
batches = ag_news_train.shuffle().batch(MAXIMUM_DATASET_SIZE)
sample = next(iter(batches))
# Load sampled data to Pandas DataFrame
pandas_df = pd.DataFrame({'text': [el[1] for el in sample],
'label': [el[0] for el in sample]})PySpark DataFrames
Files in a directory
Last updated