Skip to content

Commit

Permalink
fix: For FDA Food Enforcement, Resolve invalid source DateTime data.
Browse files Browse the repository at this point in the history
  • Loading branch information
nlarge-google committed Oct 13, 2022
1 parent 802cff6 commit 2fe2249
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def resolve_date_format(
df[col] = df[col].apply(
lambda x: convert_dt_format(str(x), from_format, to_format, is_date)
)

return df


Expand All @@ -216,6 +215,8 @@ def convert_dt_format(
rtnval = "<initial_value>"
if not dt_str or str(dt_str).lower() == "nan" or str(dt_str).lower() == "nat":
rtnval = ""
elif len(dt_str) > 20:
rtnval = ""
elif len(dt_str.strip()) == 10:
# if there is no time format
rtnval = dt_str + " 00:00:00"
Expand All @@ -239,7 +240,6 @@ def convert_dt_format(
from_format = "%Y-%m-%d " + from_format.strip().split(" ")[1]
else:
dt_str = "<blank>"

return rtnval


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion datasets/fda_food/pipelines/food_events/food_events_dag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 2fe2249

Please sign in to comment.