|
21 | 21 | from tests.system.utils import skip_legacy_pandas
|
22 | 22 |
|
23 | 23 |
|
| 24 | +def test_null_index_to_gbq(session, scalars_df_null_index, dataset_id_not_created): |
| 25 | + dataset_id = dataset_id_not_created |
| 26 | + destination_table = f"{dataset_id}.scalars_df_unindexed" |
| 27 | + |
| 28 | + result_table = scalars_df_null_index.to_gbq( |
| 29 | + destination_table, clustering_columns=["int64_col"] |
| 30 | + ) |
| 31 | + assert ( |
| 32 | + result_table == destination_table |
| 33 | + if destination_table |
| 34 | + else result_table is not None |
| 35 | + ) |
| 36 | + |
| 37 | + loaded_scalars_df_index = session.read_gbq(result_table) |
| 38 | + assert not loaded_scalars_df_index.empty |
| 39 | + |
| 40 | + |
24 | 41 | def test_null_index_materialize(scalars_df_null_index, scalars_pandas_df_default_index):
|
25 | 42 | bf_result = scalars_df_null_index.to_pandas()
|
26 | 43 | pd.testing.assert_frame_equal(
|
@@ -83,6 +100,23 @@ def test_null_index_aggregate(scalars_df_null_index, scalars_pandas_df_default_i
|
83 | 100 | )
|
84 | 101 |
|
85 | 102 |
|
| 103 | +def test_null_index_binop_series_axis_0( |
| 104 | + scalars_df_null_index, scalars_pandas_df_default_index |
| 105 | +): |
| 106 | + bf_result = ( |
| 107 | + scalars_df_null_index[["int64_col", "int64_too"]] |
| 108 | + .add(scalars_df_null_index["int64_col"], axis=0) |
| 109 | + .to_pandas() |
| 110 | + ) |
| 111 | + pd_result = scalars_pandas_df_default_index[["int64_col", "int64_too"]].add( |
| 112 | + scalars_pandas_df_default_index.int64_col, axis=0 |
| 113 | + ) |
| 114 | + |
| 115 | + pd.testing.assert_frame_equal( |
| 116 | + bf_result, pd_result, check_dtype=False, check_index_type=False |
| 117 | + ) |
| 118 | + |
| 119 | + |
86 | 120 | def test_null_index_groupby_aggregate(
|
87 | 121 | scalars_df_null_index, scalars_pandas_df_default_index
|
88 | 122 | ):
|
@@ -139,6 +173,25 @@ def test_null_index_merge_left_null_index_object(
|
139 | 173 | assert got.shape == expected.shape
|
140 | 174 |
|
141 | 175 |
|
| 176 | +@skip_legacy_pandas |
| 177 | +@pytest.mark.parametrize( |
| 178 | + ("expr",), |
| 179 | + [ |
| 180 | + ("new_col = int64_col + int64_too",), |
| 181 | + ("new_col = (rowindex > 3) | bool_col",), |
| 182 | + ("int64_too = bool_col\nnew_col2 = rowindex",), |
| 183 | + ], |
| 184 | +) |
| 185 | +def test_null_index_df_eval( |
| 186 | + scalars_df_null_index, scalars_pandas_df_default_index, expr |
| 187 | +): |
| 188 | + |
| 189 | + bf_result = scalars_df_null_index.eval(expr).to_pandas() |
| 190 | + pd_result = scalars_pandas_df_default_index.eval(expr) |
| 191 | + |
| 192 | + pd.testing.assert_frame_equal(bf_result, pd_result, check_index_type=False) |
| 193 | + |
| 194 | + |
142 | 195 | def test_null_index_merge_right_null_index_object(
|
143 | 196 | scalars_df_null_index, scalars_df_default_index, scalars_pandas_df_default_index
|
144 | 197 | ):
|
|
0 commit comments