Skip to content

feat: add 'columns' as an alias for 'col_order' #701

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

Merged
merged 18 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Made col_order a keyword argument and added to-do
  • Loading branch information
kiraksi committed Nov 28, 2023
commit 6d7f8219bd2277ff70a218878f00fdcdef066cc0
10 changes: 6 additions & 4 deletions pandas_gbq/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ def read_gbq(
query_or_table,
project_id=None,
index_col=None,
col_order=None,
columns=None,
reauth=False,
auth_local_webserver=True,
Expand All @@ -751,6 +750,8 @@ def read_gbq(
auth_redirect_uri=None,
client_id=None,
client_secret=None,
*,
col_order=None,
):
r"""Load data from Google BigQuery using google-cloud-python

Expand All @@ -774,11 +775,9 @@ def read_gbq(
the environment.
index_col : str, optional
Name of result column to use for index in results DataFrame.
col_order : list(str), optional
columns : list(str), optional
List of BigQuery column names in the desired order for results
DataFrame.
columns : list(str), optional
Alias for col_order
reauth : boolean, default False
Force Google BigQuery to re-authenticate the user. This is useful
if multiple accounts are used.
Expand Down Expand Up @@ -891,6 +890,8 @@ def read_gbq(
client_secret : str
The Client Secret associated with the Client ID for the Google Cloud Project
the user is attempting to connect to.
col_order : list(str), optional
Alias for columns, retained for backwards compatibility.

Returns
-------
Expand Down Expand Up @@ -976,6 +977,7 @@ def read_gbq(
raise ValueError("Must specify either columns or col_order, not both")

# Change the order of columns in the DataFrame based on provided list
# TO DO: allow columns to be a subset of all columns in the table, with follow up PR
if columns is not None:
if sorted(columns) == sorted(final_df.columns):
final_df = final_df[columns]
Expand Down