Skip to content

Commit

Permalink
guard for string value and ensure consistent columns
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Jan 19, 2022
1 parent a0d583f commit 52808f3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stormevents/coops/tidalstations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import bs4
from bs4 import BeautifulSoup
import numpy
import pandas
from pandas import DataFrame
import requests
Expand Down Expand Up @@ -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}

Expand All @@ -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

Expand Down

0 comments on commit 52808f3

Please sign in to comment.