Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,6 @@ def test_list_rows_max_results_w_bqstorage(bigquery_client):
assert len(dataframe.index) == 100


@pytest.mark.skipif(PANDAS_INSTALLED_VERSION[0:2] not in ["0.", "1."], reason="")
@pytest.mark.parametrize(
("max_results",),
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,15 @@ def test_bq_to_arrow_array_w_nullable_scalars(module_under_test, bq_type, rows):
],
)
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
@pytest.mark.skipif(PANDAS_INSTALLED_VERSION[0:2] not in ["0.", "1."], reason="")
@pytest.mark.skipif(isinstance(pyarrow, mock.Mock), reason="Requires `pyarrow`")
def test_bq_to_arrow_array_w_pandas_timestamp(module_under_test, bq_type, rows):
rows = [pandas.Timestamp(row) for row in rows]
series = pandas.Series(rows)
bq_field = schema.SchemaField("field_name", bq_type)
arrow_array = module_under_test.bq_to_arrow_array(series, bq_field)
roundtrip = arrow_array.to_pandas()
assert series.equals(roundtrip)
series = series.astype(roundtrip.dtype)
pandas.testing.assert_series_equal(series, roundtrip)
Comment on lines +561 to +562
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While pandas.testing.assert_series_equal provides better diagnostic information than Series.equals(), it is stricter and validates the name attribute by default. Since series is initialized without a name (line 557) and roundtrip might have a name assigned during the Arrow-to-Pandas conversion (e.g., from bq_field.name), this assertion may fail. Adding check_names=False ensures the test continues to focus on value equality, maintaining consistency with the previous equals() check.

Suggested change
series = series.astype(roundtrip.dtype)
pandas.testing.assert_series_equal(series, roundtrip)
series = series.astype(roundtrip.dtype)
pandas.testing.assert_series_equal(series, roundtrip, check_names=False)



@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
Expand Down
Loading