cathw commited on
Commit
6098eb8
·
verified ·
1 Parent(s): eb06ee6

Upload reddit_climate_comment.py

Browse files
Files changed (1) hide show
  1. reddit_climate_comment.py +5 -1
reddit_climate_comment.py CHANGED
@@ -56,6 +56,9 @@ class NewDataset(GeneratorBasedBuilder):
56
  def _generate_examples(self, filepath):
57
  df = pd.read_csv(filepath)
58
 
 
 
 
59
  # Group the DataFrame by post ID
60
  grouped_df = df.groupby('PostID')
61
 
@@ -75,7 +78,7 @@ class NewDataset(GeneratorBasedBuilder):
75
  comments = []
76
 
77
  # Extract comment data
78
- for index, comment_row in group.iterrows():
79
  comment_id = str(comment_row['CommentID'])
80
 
81
  if pd.isna(comment_id): # Skip if CommentID is NaN
@@ -125,5 +128,6 @@ class NewDataset(GeneratorBasedBuilder):
125
 
126
 
127
 
 
128
 
129
 
 
56
  def _generate_examples(self, filepath):
57
  df = pd.read_csv(filepath)
58
 
59
+ # Remove duplicate comment IDs
60
+ df = df.drop_duplicates(subset=['CommentID'])
61
+
62
  # Group the DataFrame by post ID
63
  grouped_df = df.groupby('PostID')
64
 
 
78
  comments = []
79
 
80
  # Extract comment data
81
+ for _, comment_row in group.iterrows():
82
  comment_id = str(comment_row['CommentID'])
83
 
84
  if pd.isna(comment_id): # Skip if CommentID is NaN
 
128
 
129
 
130
 
131
+
132
 
133