A way to handle datetime column error "AttributeError: Can only use .dt accessor with datetimelike values" in athena.read_sql_query #2002
helios1014
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So sometimes, when querying datetime columns from Athena, one might have an issue but not all of them. To look into that, I arrived at the following solution whereby I create a custom function for the Athena CSV to avoid the conversion issue with datetime objects and mark which columns are throwing the initial error:
Then you simply run wr.athena.read_sql_query as you normally would and instead of nothing, you get a dataframe you can examine for issues in your data and repair accordingly.
Beta Was this translation helpful? Give feedback.
All reactions