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

Timestamp returns a different type depending on whether the data is empty or not. #852

Open
kitagry opened this issue Jan 9, 2025 · 1 comment · May be fixed by #858
Open

Timestamp returns a different type depending on whether the data is empty or not. #852

kitagry opened this issue Jan 9, 2025 · 1 comment · May be fixed by #858
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery-pandas API.

Comments

@kitagry
Copy link

kitagry commented Jan 9, 2025

Environment details

  • OS type and version: macOS sonoma 14.6
  • Python version: 3.11.9
  • pip version: I use rye instead of pip. and rye version is 0.35
  • pandas-gbq version: 0.26.1
  • pandas version: 2.2.2

Code example

import pandas_gbq

df = pandas_gbq.read_gbq('SELECT timestamp FROM `bigquery-public-data.pypi.file_downloads` LIMIT 1')
print(df.dtypes)

df = pandas_gbq.read_gbq('SELECT timestamp FROM `bigquery-public-data.pypi.file_downloads` LIMIT 0')
print(df.dtypes)

got the following. I expected either us or ns

timestamp    datetime64[us, UTC]
dtype: object
timestamp    datetime64[ns, UTC]
dtype: object

When I downgrade pandas version to 1.5.3, the above both code returns datetime64[ns, UTC].

Thanks!

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-pandas API. label Jan 9, 2025
@tswast tswast assigned tswast and unassigned orrbradford Jan 27, 2025
@tswast
Copy link
Collaborator

tswast commented Jan 27, 2025

Thanks @kitagry for the report and the proposed fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-pandas API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants