Skip to content

Commit acdc540

Browse files
committed
update
1 parent 8b24be6 commit acdc540

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

leetcode-master/scratch_codes/pytorch_huggingface_tutorial/slice_dice_dataset.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,18 @@ def filter_nones(x):
3636
# Check that lowercasing worked
3737

3838
print(f'check if lower casing worked -> {drug_dataset["train"]["condition"][:3]}')
39+
40+
# Creating new columns
41+
42+
def compute_review_length(example):
43+
return {"review_length": len(example["review"].split())}
44+
45+
46+
drug_dataset = drug_dataset.map(compute_review_length)
47+
# Inspect the first training example
48+
print(f"Inspect the first training example -> {drug_dataset['train'][0]}")
49+
print(f"sort the dataset with the new column -> {drug_dataset["train"].sort("review_length")[:3]}")
50+
51+
# Datasets + Dataframe = Pandas <B
52+
53+

0 commit comments

Comments
 (0)