Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: For FDA Food Enforcement, Resolve invalid source DateTime data. #508

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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