1414
1515import base64
1616import decimal
17+ import re
1718from typing import Iterable , Optional , Sequence , Set , Union
1819
1920import geopandas as gpd # type: ignore
6970]
7071
7172
73+ def pandas_major_version () -> int :
74+ match = re .search (r"^v?(\d+)" , pd .__version__ .strip ())
75+ assert match is not None
76+ return int (match .group (1 ))
77+
78+
7279# Prefer this function for tests that run in both ordered and unordered mode
7380def assert_dfs_equivalent (pd_df : pd .DataFrame , bf_df : bpd .DataFrame , ** kwargs ):
7481 bf_df_local = bf_df .to_pandas ()
@@ -83,7 +90,7 @@ def assert_series_equivalent(pd_series: pd.Series, bf_series: bpd.Series, **kwar
8390
8491
8592def _normalize_all_nulls (col : pd .Series ) -> pd .Series :
86- if col .dtype == bigframes .dtypes .FLOAT_DTYPE :
93+ if col .dtype in ( bigframes .dtypes .FLOAT_DTYPE , bigframes . dtypes . INT_DTYPE ) :
8794 col = col .astype ("float64" )
8895 if pd_types .is_object_dtype (col ):
8996 col = col .fillna (float ("nan" ))
@@ -134,6 +141,15 @@ def assert_series_equal(
134141 left = left .sort_index ()
135142 right = right .sort_index ()
136143
144+ if isinstance (left .index , pd .RangeIndex ) or pd_types .is_integer_dtype (
145+ left .index .dtype ,
146+ ):
147+ left .index = left .index .astype ("Int64" )
148+ if isinstance (right .index , pd .RangeIndex ) or pd_types .is_integer_dtype (
149+ right .index .dtype ,
150+ ):
151+ right .index = right .index .astype ("Int64" )
152+
137153 if nulls_are_nan :
138154 left = _normalize_all_nulls (left )
139155 right = _normalize_all_nulls (right )
0 commit comments