Skip to content

Commit 5b355ef

Browse files
fix: Fix error loading local dataframes into bigquery (#1165)
1 parent e7b83f1 commit 5b355ef

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

bigframes/session/loader.py

+2
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,12 @@ def read_pandas_load_job(
158158
ordering_col = f"rowid_{suffix}"
159159
suffix += 1
160160

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

166168
job_config = bigquery.LoadJobConfig()
167169
# Specify the datetime dtypes, which is auto-detected as timestamp types.

tests/system/small/test_dataframe.py

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ def test_df_construct_pandas_load_job(scalars_dfs_maybe_ordered):
9999
assert_dfs_equivalent(pd_result, bf_result)
100100

101101

102+
def test_df_construct_structs(session):
103+
pd_frame = pd.Series(
104+
[
105+
{"version": 1, "project": "pandas"},
106+
{"version": 2, "project": "pandas"},
107+
{"version": 1, "project": "numpy"},
108+
]
109+
).to_frame()
110+
bf_series = session.read_pandas(pd_frame)
111+
pd.testing.assert_frame_equal(
112+
bf_series.to_pandas(), pd_frame, check_index_type=False, check_dtype=False
113+
)
114+
115+
102116
def test_df_construct_pandas_set_dtype(scalars_dfs):
103117
columns = [
104118
"int64_too",

0 commit comments

Comments
 (0)