Skip to content

Commit 02fbad3

Browse files
authored
Dev fix (#56)
* Fixed get_observation bug * Fixed key error * Use new col name
1 parent 7de103e commit 02fbad3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

datacommons/populations.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_observations(self,
109109
observation_date,
110110
measured_property,
111111
stats_type=None,
112-
clean_data=True,
112+
clean_data=False,
113113
rows=100):
114114
"""Create a new column with values for an observation of the given property.
115115
The current pandas dataframe should include a column containing population
@@ -179,13 +179,13 @@ def get_observations(self,
179179
if measurement_method:
180180
query.add_constraint('?o', 'measurementMethod', measurement_method)
181181

182-
# Check if data should be cleaned
183-
clean_func = None
184-
if clean_data:
185-
type_func = utils.convert_type(new_col_var, 'float')
186-
nan_func = utils.drop_nan(new_col_var)
187-
clean_func = utils.compose_process(type_func, nan_func)
188-
189182
# Perform the query and merge the results
190-
new_frame = DCFrame(datalog_query=query, labels=labels, process=clean_func, type_hint=type_hint, rows=rows)
183+
new_frame = DCFrame(datalog_query=query, labels=labels, type_hint=type_hint, rows=rows)
191184
self.merge(new_frame)
185+
186+
# After the merge is performed, check if cleaning needs to be done
187+
if clean_data:
188+
type_func = utils.convert_type(new_col_name, 'float')
189+
nan_func = utils.drop_nan(new_col_name)
190+
clean_func = utils.compose_process(type_func, nan_func)
191+
self._dataframe = clean_func(self._dataframe)

0 commit comments

Comments
 (0)