googleapis / googleapis/google-cloud-python

add `index=True` option to `to_gbq`

Open
#14,481 0 comments 0 reactions 1 assignee Claimed by @tswast View on GitHub
api: bigquery type: feature request
Dominant language
Python
Stars
5.4k
Forks
1.8k
Avg merge
3d 4h
Merged PRs (30d)
122

Description

**Is your feature request related to a problem? Please describe.**

I'd like to be able to control when the DataFrame Index/MultiIndex is included in the serialized BigQuery table.

**Describe the solution you'd like**

I'd like a boolean parameter `index=True` to enable writing the index column(s) to the BigQuery table. For backwards compatibility, we might need to keep this parameter `False` by default.

**Describe alternatives you've considered**

Folks can always call `DataFrame.reset_index(drop=False)` before uploading if they want this behavior, but I do think it'd be nice to be consistent with other I/O methods.

**Additional context**

* https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_parquet.html (Has three options, where None is like True but serializes RangeIndex to metadata instead of as a column)
* https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html (index=True by default. Also includes an index_label="string-here" parameter to override the index name)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.