Skip to content

Commit 5c546e7

Browse files
committed
set convertType to default or user specification
1 parent f5cca07 commit 5c546e7

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

dataretrieval/waterdata.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ def get_daily(
237237
k: v for k, v in locals().items()
238238
if k not in {"service", "output_id"} and v is not None
239239
}
240-
args["convertType"] = False
241240

242241
return waterdata_helpers.get_ogc_data(args, output_id, service)
243242

@@ -536,7 +535,6 @@ def get_monitoring_locations(
536535
k: v for k, v in locals().items()
537536
if k not in {"service", "output_id"} and v is not None
538537
}
539-
args["convertType"] = False
540538

541539
return waterdata_helpers.get_ogc_data(args, output_id, service)
542540

@@ -723,7 +721,6 @@ def get_time_series_metadata(
723721
k: v for k, v in locals().items()
724722
if k not in {"service", "output_id"} and v is not None
725723
}
726-
args["convertType"] = False
727724

728725
return waterdata_helpers.get_ogc_data(args, output_id, service)
729726

@@ -889,7 +886,6 @@ def get_latest_continuous(
889886
k: v for k, v in locals().items()
890887
if k not in {"service", "output_id"} and v is not None
891888
}
892-
args["convertType"] = False
893889

894890
return waterdata_helpers.get_ogc_data(args, output_id, service)
895891

@@ -1055,7 +1051,6 @@ def get_field_measurements(
10551051
k: v for k, v in locals().items()
10561052
if k not in {"service", "output_id"} and v is not None
10571053
}
1058-
args["convertType"] = False
10591054

10601055
return waterdata_helpers.get_ogc_data(args, output_id, service)
10611056

dataretrieval/waterdata_helpers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import httpx
22
import os
3-
import warnings
43
from typing import List, Dict, Any, Optional, Union
54
from datetime import datetime
65
import pandas as pd
76
import json
8-
from datetime import datetime
97
from zoneinfo import ZoneInfo
108
import re
119
try:
@@ -158,9 +156,6 @@ def _format_api_dates(datetime_input: Union[str, List[str]], date: bool = False)
158156
if all(pd.isna(dt) or dt == "" or dt == None for dt in datetime_input):
159157
return None
160158

161-
# Replace all blanks with "nan"
162-
datetime_input = ["nan" if x == "" else x for x in datetime_input]
163-
164159
if len(datetime_input) <=2:
165160
# If the list is of length 1, first look for things like "P7D" or dates
166161
# already formatted in ISO08601. Otherwise, try to coerce to datetime
@@ -185,7 +180,7 @@ def _format_api_dates(datetime_input: Union[str, List[str]], date: bool = False)
185180
else:
186181
parsed_locals = [dt.replace(tzinfo=local_timezone) for dt in parsed_dates]
187182
formatted = "/".join(dt.astimezone(ZoneInfo("UTC")).strftime("%Y-%m-%dT%H:%M:%SZ") for dt in parsed_locals)
188-
return formatted.replace("nan", "..")
183+
return formatted
189184
else:
190185
raise ValueError("datetime_input should only include 1-2 values")
191186

@@ -407,6 +402,7 @@ def _get_resp_data(resp: httpx.Response, geopd: bool) -> pd.DataFrame:
407402
sep="_")
408403
df = df.drop(columns=["type", "geometry", "AsGeoJSON(geometry)"], errors="ignore")
409404
df.columns = [col.replace("properties_", "") for col in df.columns]
405+
df.rename(columns={"geometry_coordinates": "geometry"}, inplace=True)
410406
return df
411407

412408
# Organize json into geodataframe and make sure id column comes along.

0 commit comments

Comments
 (0)