Datasets:
Commit
·
de10781
1
Parent(s):
33297bc
nan values
Browse files- b2w-reviews01.py +5 -9
b2w-reviews01.py
CHANGED
@@ -59,21 +59,17 @@ class Reviews(datasets.GeneratorBasedBuilder):
|
|
59 |
def _generate_examples(self, filepath):
|
60 |
def process_row(row):
|
61 |
|
62 |
-
row["overall_rating"] = int(row["overall_rating"])
|
63 |
-
|
64 |
-
try:
|
65 |
-
row["reviewer_birth_year"] = int(float(row["reviewer_birth_year"]))
|
66 |
-
except ValueError:
|
67 |
-
row["reviewer_birth_year"] = None
|
68 |
-
|
69 |
for key, value in row.items():
|
70 |
if pd.isnull(value):
|
71 |
row[key] = None
|
72 |
|
|
|
|
|
|
|
|
|
|
|
73 |
return row
|
74 |
|
75 |
records = pd.read_csv(filepath).to_dict("records")
|
76 |
for idx, row in enumerate(records):
|
77 |
-
if idx < 10:
|
78 |
-
print(row)
|
79 |
yield idx, process_row(row)
|
|
|
59 |
def _generate_examples(self, filepath):
|
60 |
def process_row(row):
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
for key, value in row.items():
|
63 |
if pd.isnull(value):
|
64 |
row[key] = None
|
65 |
|
66 |
+
row["overall_rating"] = int(row["overall_rating"])
|
67 |
+
|
68 |
+
if row["reviewer_birth_year"] is not None:
|
69 |
+
row["reviewer_birth_year"] = int(float(row["reviewer_birth_year"]))
|
70 |
+
|
71 |
return row
|
72 |
|
73 |
records = pd.read_csv(filepath).to_dict("records")
|
74 |
for idx, row in enumerate(records):
|
|
|
|
|
75 |
yield idx, process_row(row)
|