Skip to content

Commit f2f2112

Browse files
jasonqngtswast
authored andcommitted
BUG: Use object dtype when querying an array of floats (#134)
* Fix array of floats bug * Update changelog
1 parent 5666e6d commit f2f2112

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

docs/source/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
0.3.2 / [TBD]
5+
------------------
6+
- Fix bug with querying for an array of floats (:issue:`123`)
7+
48
0.3.1 / 2018-02-13
59
------------------
610

pandas_gbq/gbq.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ def _parse_data(schema, rows):
720720
col_names = [str(field['name']) for field in fields]
721721
col_dtypes = [
722722
dtype_map.get(field['type'].upper(), object)
723+
if field['mode'] != 'repeated'
724+
else object
723725
for field in fields
724726
]
725727
page_array = np.zeros((len(rows),), dtype=lzip(col_names, col_dtypes))

pandas_gbq/tests/test_gbq.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,14 @@ def test_array_agg(self):
973973
tm.assert_frame_equal(df, DataFrame([["a", [1, 3]], ["b", [2]]],
974974
columns=["letter", "numbers"]))
975975

976+
def test_array_of_floats(self):
977+
query = """select [1.1, 2.2, 3.3] as a, 4 as b"""
978+
df = gbq.read_gbq(query, project_id=_get_project_id(),
979+
private_key=_get_private_key_path(),
980+
dialect='standard')
981+
tm.assert_frame_equal(df, DataFrame([[[1.1, 2.2, 3.3], 4]],
982+
columns=["a", "b"]))
983+
976984

977985
class TestToGBQIntegrationWithServiceAccountKeyPath(object):
978986
# Changes to BigQuery table schema may take up to 2 minutes as of May 2015

0 commit comments

Comments
 (0)