Datasets:
Upload ipums.py
Browse files
ipums.py
CHANGED
|
@@ -32,7 +32,7 @@ _CITATION = """
|
|
| 32 |
|
| 33 |
# Dataset info
|
| 34 |
urls_per_split = {
|
| 35 |
-
"train": "https://huggingface.co/datasets/mstz/ipums/
|
| 36 |
}
|
| 37 |
features_types_per_config = {
|
| 38 |
"ipums": {
|
|
@@ -109,6 +109,8 @@ class Ipums(datasets.GeneratorBasedBuilder):
|
|
| 109 |
]
|
| 110 |
|
| 111 |
def _generate_examples(self, filepath: str):
|
|
|
|
|
|
|
| 112 |
data = pandas.read_csv(filepath)
|
| 113 |
data = self.preprocess(data)
|
| 114 |
|
|
@@ -118,7 +120,6 @@ class Ipums(datasets.GeneratorBasedBuilder):
|
|
| 118 |
yield row_id, data_row
|
| 119 |
|
| 120 |
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
| 121 |
-
print(data.columns)
|
| 122 |
for feature in _ENCODING_DICS:
|
| 123 |
encoding_function = partial(self.encode, feature)
|
| 124 |
data.loc[:, feature] = data[feature].apply(encoding_function)
|
|
|
|
| 32 |
|
| 33 |
# Dataset info
|
| 34 |
urls_per_split = {
|
| 35 |
+
"train": "https://huggingface.co/datasets/mstz/ipums/resolve/main/ipums.csv.zip"
|
| 36 |
}
|
| 37 |
features_types_per_config = {
|
| 38 |
"ipums": {
|
|
|
|
| 109 |
]
|
| 110 |
|
| 111 |
def _generate_examples(self, filepath: str):
|
| 112 |
+
print("\n\n\nfilepath")
|
| 113 |
+
print(filepath)
|
| 114 |
data = pandas.read_csv(filepath)
|
| 115 |
data = self.preprocess(data)
|
| 116 |
|
|
|
|
| 120 |
yield row_id, data_row
|
| 121 |
|
| 122 |
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
|
|
|
| 123 |
for feature in _ENCODING_DICS:
|
| 124 |
encoding_function = partial(self.encode, feature)
|
| 125 |
data.loc[:, feature] = data[feature].apply(encoding_function)
|