From 798532041fa7dd3f1b2d63ac971f34b5389b8a4c Mon Sep 17 00:00:00 2001 From: Austin Raney Date: Thu, 2 Sep 2021 20:47:43 -0400 Subject: [PATCH] add helper method for creating empty canonical dataframe --- .../nwis_client/src/hydrotools/nwis_client/iv.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/nwis_client/src/hydrotools/nwis_client/iv.py b/python/nwis_client/src/hydrotools/nwis_client/iv.py index 4794488a..b45f30bc 100644 --- a/python/nwis_client/src/hydrotools/nwis_client/iv.py +++ b/python/nwis_client/src/hydrotools/nwis_client/iv.py @@ -809,3 +809,17 @@ def flatten_and_stringify(v): value_groups = np.array_split(values, n_groups) return list(map(lambda i: ",".join(i), value_groups)) + + +def _create_empty_canonical_df() -> pd.DataFrame: + """Returns an empty hydrotools canonical dataframe with correct field datatypes.""" + cols = { + "value_time": pd.Series(dtype="datetime64[ns]"), + "variable_name": pd.Series(dtype="category"), + "usgs_site_code": pd.Series(dtype="category"), + "measurement_unit": pd.Series(dtype="category"), + "value": pd.Series(dtype="float32"), + "qualifiers": pd.Series(dtype="category"), + "series": pd.Series(dtype="category"), + } + return pd.DataFrame(cols, index=[])