We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b24be6 commit acdc540Copy full SHA for acdc540
leetcode-master/scratch_codes/pytorch_huggingface_tutorial/slice_dice_dataset.py
@@ -36,3 +36,18 @@ def filter_nones(x):
36
# Check that lowercasing worked
37
38
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