From 52808f30f0ed4bea1931b6a984ce24b34e75a1f3 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Wed, 19 Jan 2022 14:49:27 -0500 Subject: [PATCH] guard for string value and ensure consistent columns --- stormevents/coops/tidalstations.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stormevents/coops/tidalstations.py b/stormevents/coops/tidalstations.py index cedaf26..252a281 100644 --- a/stormevents/coops/tidalstations.py +++ b/stormevents/coops/tidalstations.py @@ -10,6 +10,7 @@ import bs4 from bs4 import BeautifulSoup +import numpy import pandas from pandas import DataFrame import requests @@ -391,6 +392,8 @@ def coops_stations(station_type: COOPS_StationType = None) -> DataFrame: return pandas.concat( [coops_stations(station_type) for station_type in COOPS_StationType] ) + elif not isinstance(station_type, COOPS_StationType): + station_type = typepigeon.convert_value(station_type, COOPS_StationType) column_types = {'NOS ID': int, 'Latitude': float, 'Longitude': float} @@ -416,6 +419,8 @@ def coops_stations(station_type: COOPS_StationType = None) -> DataFrame: if station_type == COOPS_StationType.HISTORICAL: stations['Removed Date/Time'] = pandas.to_datetime(stations['Removed Date/Time']) + else: + stations['Removed Date/Time'] = pandas.to_datetime(numpy.nan) return stations