pnadas read_gbq is not working and showing an error

Viewed 264

I'm trying to get a data table from BigQuery with pandas. I decided to use pandas read_gbq but it is not working as I expect and get an error.

projectid = 'my-dev-2'
query = 'select * from firestore.mylog;'
df = pd.read_gbq(query, projectid, dialect='standard')

Then an error occurs

AttributeError: Can only use .dt accessor with datetimelike values

Actually, It works without a problem if I try this except timestamp columns so I guess something is wrong with the values in timestamp columns. Is there any way I could fix or ignore it?

1 Answers

Try casting the column(s) with a TIMESTAMP type to a STRING type.

e.g.

query = """
    SELECT CAST(timestamp_column AS STRING)
         , ...
    FROM   firestore.mylog;
"""
Related