Datasets:
Upload reddit_climate_comment.py
Browse files- reddit_climate_comment.py +11 -2
reddit_climate_comment.py
CHANGED
|
@@ -55,6 +55,7 @@ class NewDataset(GeneratorBasedBuilder):
|
|
| 55 |
|
| 56 |
def _generate_examples(self, filepath):
|
| 57 |
df = pd.read_csv(filepath)
|
|
|
|
| 58 |
for column in df.columns:
|
| 59 |
df[column] = df[column].replace({pd.NA: None})
|
| 60 |
# Group the DataFrame by post ID
|
|
@@ -117,8 +118,8 @@ class NewDataset(GeneratorBasedBuilder):
|
|
| 117 |
"replies": replies
|
| 118 |
}
|
| 119 |
comments.append(comment)
|
| 120 |
-
|
| 121 |
-
|
| 122 |
"id": post_id,
|
| 123 |
"post_title": post_title,
|
| 124 |
"post_author": post_author,
|
|
@@ -131,3 +132,11 @@ class NewDataset(GeneratorBasedBuilder):
|
|
| 131 |
"post_permalink": post_permalink,
|
| 132 |
"comments": comments
|
| 133 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
def _generate_examples(self, filepath):
|
| 57 |
df = pd.read_csv(filepath)
|
| 58 |
+
examples = []
|
| 59 |
for column in df.columns:
|
| 60 |
df[column] = df[column].replace({pd.NA: None})
|
| 61 |
# Group the DataFrame by post ID
|
|
|
|
| 118 |
"replies": replies
|
| 119 |
}
|
| 120 |
comments.append(comment)
|
| 121 |
+
|
| 122 |
+
example = {
|
| 123 |
"id": post_id,
|
| 124 |
"post_title": post_title,
|
| 125 |
"post_author": post_author,
|
|
|
|
| 132 |
"post_permalink": post_permalink,
|
| 133 |
"comments": comments
|
| 134 |
}
|
| 135 |
+
|
| 136 |
+
yield post_id, example
|
| 137 |
+
examples.append(example)
|
| 138 |
+
all_examples_df = pd.DataFrame(examples)
|
| 139 |
+
all_examples_df.to_parquet('cached_datasets/climate_comments.parquet')
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|