HathawayLiu
commited on
Commit
•
a7795ca
1
Parent(s):
902abf2
Update Housing_dataset.py
Browse files- Housing_dataset.py +55 -69
Housing_dataset.py
CHANGED
@@ -10,10 +10,6 @@
|
|
10 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 |
# See the License for the specific language governing permissions and
|
12 |
# limitations under the License.
|
13 |
-
# T0: Address all TODOs and remove all explanatory comments
|
14 |
-
""" TO: Add a description here.
|
15 |
-
"""
|
16 |
-
|
17 |
|
18 |
import csv
|
19 |
import json
|
@@ -23,19 +19,15 @@ import datasets
|
|
23 |
import logging
|
24 |
import pandas as pd
|
25 |
|
26 |
-
# TODO: Add BibTeX citation
|
27 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
28 |
_CITATION = """
|
29 |
@InProceedings{huggingface:dataset,
|
30 |
-
title = {
|
31 |
-
author={
|
32 |
},
|
33 |
-
year={
|
34 |
}
|
35 |
"""
|
36 |
|
37 |
-
# TODO: Add description of the dataset here
|
38 |
-
# You can copy an official description
|
39 |
_DESCRIPTION = """
|
40 |
This typical dataset contains all the building permits issued or in progress
|
41 |
within the city of Seattle starting from 1990 to recent, and this dataset is
|
@@ -43,22 +35,16 @@ still updating as time flows. Information includes permit records urls,
|
|
43 |
detailed address, and building costs etc.
|
44 |
"""
|
45 |
|
46 |
-
# TODO: Add a link to an official homepage for the dataset here
|
47 |
_HOMEPAGE = "https://data.seattle.gov/Permitting/Building-Permits/76t5-zqzr/about_data"
|
48 |
|
49 |
-
# TODO: Add the licence for the dataset here if you can find it
|
50 |
_LICENSE = " http://www.seattle.gov/sdci"
|
51 |
|
52 |
-
# TODO: Add link to the official dataset URLs here
|
53 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
54 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
55 |
_URL = "https://data.seattle.gov/Permitting/Building-Permits/76t5-zqzr/about_data"
|
56 |
_URLS = {
|
57 |
"train": "https://github.com/HathawayLiu/Housing_dataset/raw/main/housing_train_dataset.csv",
|
58 |
"test": "https://github.com/HathawayLiu/Housing_dataset/raw/main/housing_test_dataset.csv",
|
59 |
}
|
60 |
|
61 |
-
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
62 |
class HousingDataset(datasets.GeneratorBasedBuilder):
|
63 |
"""This dataset contains all building permits issued or in progress within
|
64 |
the city of Seattle. It includes the original columns in the datasets, with
|
@@ -74,33 +60,33 @@ class HousingDataset(datasets.GeneratorBasedBuilder):
|
|
74 |
features=datasets.Features(
|
75 |
{
|
76 |
# columns from original dataset
|
77 |
-
"
|
78 |
-
"
|
79 |
-
"
|
80 |
-
"
|
81 |
-
"
|
82 |
-
"
|
83 |
-
"
|
84 |
-
"
|
85 |
-
"
|
86 |
-
"
|
87 |
-
"
|
88 |
-
"
|
89 |
-
"
|
90 |
-
"
|
91 |
-
"
|
92 |
-
"
|
93 |
-
"
|
94 |
-
"
|
95 |
-
"
|
96 |
-
"
|
97 |
-
"
|
98 |
-
"
|
99 |
-
"
|
100 |
-
"
|
101 |
-
"
|
102 |
# new added columns below
|
103 |
-
"
|
104 |
}
|
105 |
),
|
106 |
# No default supervised_keys (as we have to pass both question
|
@@ -135,30 +121,30 @@ class HousingDataset(datasets.GeneratorBasedBuilder):
|
|
135 |
# Iterating through each row to generate examples
|
136 |
for index, row in housing_df.iterrows():
|
137 |
yield index, {
|
138 |
-
"
|
139 |
-
"
|
140 |
-
"
|
141 |
-
"
|
142 |
-
"
|
143 |
-
"
|
144 |
-
"
|
145 |
-
"
|
146 |
-
"
|
147 |
-
"
|
148 |
-
"
|
149 |
-
"
|
150 |
-
"
|
151 |
-
"
|
152 |
-
"
|
153 |
-
"
|
154 |
-
"
|
155 |
-
"
|
156 |
-
"
|
157 |
-
"
|
158 |
-
"
|
159 |
-
"
|
160 |
-
"
|
161 |
-
"
|
162 |
-
"
|
163 |
-
"
|
164 |
}
|
|
|
10 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 |
# See the License for the specific language governing permissions and
|
12 |
# limitations under the License.
|
|
|
|
|
|
|
|
|
13 |
|
14 |
import csv
|
15 |
import json
|
|
|
19 |
import logging
|
20 |
import pandas as pd
|
21 |
|
|
|
|
|
22 |
_CITATION = """
|
23 |
@InProceedings{huggingface:dataset,
|
24 |
+
title = {Seattle Housing Permits Dataset},
|
25 |
+
author={Xinyan(Hathaway) Liu
|
26 |
},
|
27 |
+
year={2024}
|
28 |
}
|
29 |
"""
|
30 |
|
|
|
|
|
31 |
_DESCRIPTION = """
|
32 |
This typical dataset contains all the building permits issued or in progress
|
33 |
within the city of Seattle starting from 1990 to recent, and this dataset is
|
|
|
35 |
detailed address, and building costs etc.
|
36 |
"""
|
37 |
|
|
|
38 |
_HOMEPAGE = "https://data.seattle.gov/Permitting/Building-Permits/76t5-zqzr/about_data"
|
39 |
|
|
|
40 |
_LICENSE = " http://www.seattle.gov/sdci"
|
41 |
|
|
|
|
|
|
|
42 |
_URL = "https://data.seattle.gov/Permitting/Building-Permits/76t5-zqzr/about_data"
|
43 |
_URLS = {
|
44 |
"train": "https://github.com/HathawayLiu/Housing_dataset/raw/main/housing_train_dataset.csv",
|
45 |
"test": "https://github.com/HathawayLiu/Housing_dataset/raw/main/housing_test_dataset.csv",
|
46 |
}
|
47 |
|
|
|
48 |
class HousingDataset(datasets.GeneratorBasedBuilder):
|
49 |
"""This dataset contains all building permits issued or in progress within
|
50 |
the city of Seattle. It includes the original columns in the datasets, with
|
|
|
60 |
features=datasets.Features(
|
61 |
{
|
62 |
# columns from original dataset
|
63 |
+
"PermitNum": datasets.Value("string"),
|
64 |
+
"PermitClass": datasets.Value("string"),
|
65 |
+
"PermitClassMapped": datasets.Value("string"),
|
66 |
+
"PermitTypeMapped": datasets.Value("string"),
|
67 |
+
"PermitTypeDesc": datasets.Value("string"),
|
68 |
+
"Description": datasets.Value("string"),
|
69 |
+
"HousingUnits": datasets.Value("int64"),
|
70 |
+
"HousingUnitsRemoved": datasets.Value("int64"),
|
71 |
+
"HousingUnitsAdded": datasets.Value("int64"),
|
72 |
+
"EstProjectCost": datasets.Value("float32"),
|
73 |
+
"AppliedDate": datasets.Value("string"),
|
74 |
+
"IssuedDate": datasets.Value("string"),
|
75 |
+
"ExpiresDate": datasets.Value("string"),
|
76 |
+
"CompletedDate": datasets.Value("string"),
|
77 |
+
"StatusCurrent": datasets.Value("string"),
|
78 |
+
"RelatedMup": datasets.Value("string"),
|
79 |
+
"OriginalAddress1": datasets.Value("string"),
|
80 |
+
"OriginalCity": datasets.Value("string"),
|
81 |
+
"OriginalState": datasets.Value("string"),
|
82 |
+
"OriginalZip": datasets.Value("int64"),
|
83 |
+
"ContractorCompanyName": datasets.Value("string"),
|
84 |
+
"Link": datasets.Value("string"),
|
85 |
+
"Latitude": datasets.Value("float32"),
|
86 |
+
"Longitude": datasets.Value("float32"),
|
87 |
+
"Location1": datasets.Value("string"),
|
88 |
# new added columns below
|
89 |
+
"NeighborDistrict": datasets.Value("string")
|
90 |
}
|
91 |
),
|
92 |
# No default supervised_keys (as we have to pass both question
|
|
|
121 |
# Iterating through each row to generate examples
|
122 |
for index, row in housing_df.iterrows():
|
123 |
yield index, {
|
124 |
+
"PermitNum": row.get("PermitNum", ""),
|
125 |
+
"PermitClass": row.get("PermitClass", ""),
|
126 |
+
"PermitClassMapped": row.get("PermitClassMapped", ""),
|
127 |
+
"PermitTypeMapped": row.get("PermitTypeMapped", ""),
|
128 |
+
"PermitTypeDesc": row.get("PermitTypeDesc", ""),
|
129 |
+
"Description": row.get("Description", ""),
|
130 |
+
"HousingUnits": int(row.get("HousingUnits", "")),
|
131 |
+
"HousingUnitsRemoved": int(row.get("HousingUnitsRemoved", "")),
|
132 |
+
"HousingUnitsAdded": int(row.get("HousingUnitsAdded", "")),
|
133 |
+
"EstProjectCost": float(row.get("EstProjectCost", "")),
|
134 |
+
"AppliedDate": str(row.get("AppliedDate", "")),
|
135 |
+
"IssuedDate": str(row.get("IssuedDate", "")),
|
136 |
+
"ExpiresDate": str(row.get("ExpiresDate", "")),
|
137 |
+
"CompletedDate": str(row.get("CompletedDate", "")),
|
138 |
+
"StatusCurrent": row.get("StatusCurrent", ""),
|
139 |
+
"RelatedMup": row.get("RelatedMup", ""),
|
140 |
+
"OriginalAddress1": row.get("OriginalAddress1", ""),
|
141 |
+
"OriginalCity": row.get("OriginalCity", ""),
|
142 |
+
"OriginalState": row.get("OriginalState", ""),
|
143 |
+
"OriginalZip": int(row.get("OriginalZip", "")),
|
144 |
+
"ContractorCompanyName": row.get("ContractorCompanyName", ""),
|
145 |
+
"Link": row.get("Link", ""),
|
146 |
+
"Latitude": row["Latitude"],
|
147 |
+
"Longitude": row["Longitude"],
|
148 |
+
"Location1": str(row["Latitude"]) + ", " + str(row["Longitude"]),
|
149 |
+
"NeighborDistrict": row.get("NeighborDistrict", "")
|
150 |
}
|