EricR401S commited on
Commit
3fb5a0e
·
1 Parent(s): c6be7ba

annoying colab

Browse files
Files changed (1) hide show
  1. Pill_Ideologies-Post_Titles.py +17 -1
Pill_Ideologies-Post_Titles.py CHANGED
@@ -166,7 +166,23 @@ class SubRedditPosts(datasets.GeneratorBasedBuilder):
166
  urls = _URLS[self.config.name]
167
  data_dir = dl_manager.download_and_extract(urls)
168
  data = pd.read_csv(data_dir)
169
- data.fillna("NAN -Nothing found", inplace=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
  # make splits
172
  # train, test = train_test_split(
 
166
  urls = _URLS[self.config.name]
167
  data_dir = dl_manager.download_and_extract(urls)
168
  data = pd.read_csv(data_dir)
169
+
170
+ def clean_data_nans(data):
171
+ """This function takes a dataframe and fills all NaNs with a value
172
+ This is to appease google colab, because my local machine did not raise errors
173
+ ... and it's a windows. That should tell you a lot."""
174
+ for col in data.columns:
175
+ if col.dtype == "object":
176
+ data[col].fillna("NAN -Nothing found", inplace=True)
177
+ elif col.dtype == "int64" or col.dtype == "float64":
178
+ data[col].fillna(0, inplace=True)
179
+ else:
180
+ data[col].fillna("NAN - problematic {col} found", inplace=True)
181
+ return None
182
+
183
+ clean_data_nans(data)
184
+ # commented out the splits, due to google colab being uncooperative
185
+ # raised too many errors that my local machine did not
186
 
187
  # make splits
188
  # train, test = train_test_split(