8000 fix: Fix error loading local dataframes into bigquery by TrevorBergeron · Pull Request #1165 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions bigframes/session/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ def read_pandas_load_job(
ordering_col = f"rowid_{suffix}"
suffix += 1

# Maybe should just convert to pyarrow or parquet?
pandas_dataframe_copy = pandas_dataframe.copy()
pandas_dataframe_copy.index.names = new_idx_ids
pandas_dataframe_copy.columns = pandas.Index(new_col_ids)
pandas_dataframe_copy[ordering_col] = np.arange(pandas_dataframe_copy.shape[0])
pandas_dataframe_copy = pandas_dataframe_copy.reset_index(drop=False)

job_config = bigquery.LoadJobConfig()
# Specify the datetime dtypes, which is auto-detected as timestamp types.
Expand Down
14 changes: 14 additions & 0 deletions tests/system/small/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ def test_df_construct_pandas_load_job(scalars_dfs_maybe_ordered):
assert_dfs_equivalent(pd_result, bf_result)


def test_df_construct_structs(session):
pd_frame = pd.Series(
[
{"version": 1, "project": "pandas"},
{"version": 2, "project": "pandas"},
{"version": 1, "project": "numpy"},
]
).to_frame()
bf_series = session.read_pandas(pd_frame)
pd.testing.assert_frame_equal(
bf_series.to_pandas(), pd_frame, check_index_type=False, check_dtype=False
)


def test_df_construct_pandas_set_dtype(scalars_dfs):
columns = [
"int64_too",
Expand Down
0