Datasets:
Upload adult.py
Browse files
adult.py
CHANGED
@@ -181,6 +181,12 @@ class Adult(datasets.GeneratorBasedBuilder):
|
|
181 |
def _generate_examples(self, filepath: str):
|
182 |
if self.config.name == "encoding":
|
183 |
data = self.encodings()
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
elif self.config.name in ["income", "income-no race", "race"]:
|
185 |
data = pandas.read_csv(filepath)
|
186 |
data = self.preprocess(data, config=self.config.name)
|
@@ -189,6 +195,7 @@ class Adult(datasets.GeneratorBasedBuilder):
|
|
189 |
data_row = dict(row)
|
190 |
|
191 |
yield row_id, data_row
|
|
|
192 |
else:
|
193 |
raise ValueError(f"Unknown config: {self.config.name}")
|
194 |
|
@@ -201,7 +208,9 @@ class Adult(datasets.GeneratorBasedBuilder):
|
|
201 |
for original_value, encoded_value in _RACE_ENCODING.items()],
|
202 |
columns=["feature", "original_value", "encoded_value"]))
|
203 |
data = pandas.concat(data, axis="rows").reset_index()
|
|
|
204 |
data.drop("index", axis="columns", inplace=True)
|
|
|
205 |
|
206 |
return data
|
207 |
|
|
|
181 |
def _generate_examples(self, filepath: str):
|
182 |
if self.config.name == "encoding":
|
183 |
data = self.encodings()
|
184 |
+
|
185 |
+
for row_id, row in data.iterrows():
|
186 |
+
data_row = dict(row)
|
187 |
+
|
188 |
+
yield row_id, data_row
|
189 |
+
|
190 |
elif self.config.name in ["income", "income-no race", "race"]:
|
191 |
data = pandas.read_csv(filepath)
|
192 |
data = self.preprocess(data, config=self.config.name)
|
|
|
195 |
data_row = dict(row)
|
196 |
|
197 |
yield row_id, data_row
|
198 |
+
|
199 |
else:
|
200 |
raise ValueError(f"Unknown config: {self.config.name}")
|
201 |
|
|
|
208 |
for original_value, encoded_value in _RACE_ENCODING.items()],
|
209 |
columns=["feature", "original_value", "encoded_value"]))
|
210 |
data = pandas.concat(data, axis="rows").reset_index()
|
211 |
+
print(data)
|
212 |
data.drop("index", axis="columns", inplace=True)
|
213 |
+
print(data)
|
214 |
|
215 |
return data
|
216 |
|