Skip to content

Commit 27764a6

Browse files
authored
fix: astype Decimal to Int64 conversion. (#957)
* fix: astype Decimal to Int64 conversion. * update format
1 parent 6fdb6b1 commit 27764a6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

bigframes/core/compile/ibis_types.py

+2
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ def cast_ibis_value(
144144
),
145145
ibis_dtypes.Decimal(precision=38, scale=9): (
146146
ibis_dtypes.float64,
147+
ibis_dtypes.int64,
147148
ibis_dtypes.Decimal(precision=76, scale=38),
148149
),
149150
ibis_dtypes.Decimal(precision=76, scale=38): (
150151
ibis_dtypes.float64,
152+
ibis_dtypes.int64,
151153
ibis_dtypes.Decimal(precision=38, scale=9),
152154
),
153155
ibis_dtypes.time: (

tests/system/small/test_series.py

+10
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,16 @@ def test_astype(scalars_df_index, scalars_pandas_df_index, column, to_type):
30803080
pd.testing.assert_series_equal(bf_result, pd_result)
30813081

30823082

3083+
@skip_legacy_pandas
3084+
def test_astype_numeric_to_int(scalars_df_index, scalars_pandas_df_index):
3085+
column = "numeric_col"
3086+
to_type = "Int64"
3087+
bf_result = scalars_df_index[column].astype(to_type).to_pandas()
3088+
# Round to the nearest whole number to avoid TypeError
3089+
pd_result = scalars_pandas_df_index[column].round(0).astype(to_type)
3090+
pd.testing.assert_series_equal(bf_result, pd_result)
3091+
3092+
30833093
@pytest.mark.parametrize(
30843094
("column", "to_type"),
30853095
[

0 commit comments

Comments
 (0)