File size: 709 Bytes
ba39550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import pandas as pd
from datasets import Dataset, DatasetDict

# Load the JSON data
with open('tech_quotes.json', 'r') as f:
    data = json.load(f)

# Convert JSON data to a DataFrame
df = pd.DataFrame(data)

# Create a Hugging Face dataset
dataset = Dataset.from_pandas(df)

# Optionally, split the dataset into train and test sets
train_test_split = dataset.train_test_split(test_size=0.2)
dataset_dict = DatasetDict({
    'train': train_test_split['train'],
    'test': train_test_split['test']
})

# Save the dataset locally
dataset_dict.save_to_disk('tech_quotes_dataset')

# Optionally, push the dataset to the Hugging Face Hub
dataset_dict.push_to_hub('your-username/tech-quotes-dataset')