Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions awswrangler/athena/_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def _fix_csv_types(df: pd.DataFrame, parse_dates: List[str], binaries: List[str]
"""Apply data types cast to a Pandas DataFrames."""
if len(df.index) > 0:
for col in parse_dates:
try:
if pd.api.types.is_datetime64_any_dtype(df[col]):
df[col] = df[col].dt.date.replace(to_replace={pd.NaT: None})
except AttributeError:
else:
df[col] = (
df[col].replace(to_replace={pd.NaT: None}).apply(lambda x: date.fromisoformat(x) if x else None)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,4 +1401,4 @@ def test_athena_date_recovery(path, glue_database, glue_table):
database=glue_database,
ctas_approach=False,
)
assert df.equals(df2)
assert pandas_equals(df, df2)