ruanchaves commited on
Commit
0df8277
1 Parent(s): 15c6031

initial reader - bug fix

Browse files
Files changed (1) hide show
  1. b2w-reviews01.py +8 -1
b2w-reviews01.py CHANGED
@@ -53,7 +53,7 @@ class Reviews(datasets.GeneratorBasedBuilder):
53
  overall_rating=datasets.Value("string"),
54
  recommend_to_a_friend=datasets.Value("string"),
55
  review_text=datasets.Value("string"),
56
- reviewer_birth_year=datasets.Value("string"),
57
  reviewer_gender=datasets.Value("string"),
58
  reviewer_state=datasets.Value("string"))),
59
  supervised_keys=None,
@@ -74,6 +74,13 @@ class Reviews(datasets.GeneratorBasedBuilder):
74
 
75
  def _generate_examples(self, filepath):
76
  def process_row(row):
 
 
 
 
 
 
 
77
  return row
78
  records = pd.read_csv(filepath).to_dict("records")
79
  for idx, row in enumerate(records):
 
53
  overall_rating=datasets.Value("string"),
54
  recommend_to_a_friend=datasets.Value("string"),
55
  review_text=datasets.Value("string"),
56
+ reviewer_birth_year=datasets.Value("int32"),
57
  reviewer_gender=datasets.Value("string"),
58
  reviewer_state=datasets.Value("string"))),
59
  supervised_keys=None,
 
74
 
75
  def _generate_examples(self, filepath):
76
  def process_row(row):
77
+
78
+ row["reviewer_birth_year"] = int(float(row["reviewer_birth_year"]))
79
+
80
+ for key, value in row.items():
81
+ if value == "nan":
82
+ row[key] = None
83
+
84
  return row
85
  records = pd.read_csv(filepath).to_dict("records")
86
  for idx, row in enumerate(records):