Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: Fix Null index assign series to column #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions 11 bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ def memory_usage(self, index: bool = True):
column_sizes = self.dtypes.map(
lambda dtype: bigframes.dtypes.DTYPE_BYTE_SIZES.get(dtype, 8) * n_rows
)
if index:
if index and self._has_index:
index_size = pandas.Series([self.index._memory_usage()], index=["Index"])
column_sizes = pandas.concat([index_size, column_sizes])
return column_sizes

@requires_index
def info(
self,
verbose: Optional[bool] = None,
Expand Down Expand Up @@ -768,7 +769,7 @@ def _apply_series_binop_axis_0(
block = block.drop_columns([get_column_left[column_id]])

block = block.drop_columns([series_col])
block = block.with_index_labels(self.index.names)
block = block.with_index_labels(self._block.index.names)
return DataFrame(block)

def _apply_series_binop_axis_1(
Expand Down Expand Up @@ -1611,7 +1612,7 @@ def _assign_series_join_on_index(
# Update case, remove after copying into columns
block = block.drop_columns([source_column])

return DataFrame(block.with_index_labels(self.index.names))
return DataFrame(block.with_index_labels(self._block.index.names))

def reset_index(self, *, drop: bool = False) -> DataFrame:
block = self._block.reset_index(drop)
Expand Down Expand Up @@ -3283,7 +3284,7 @@ def _prepare_export(
array_value = self._block.expr

new_col_labels, new_idx_labels = utils.get_standardized_ids(
self._block.column_labels, self.index.names
self._block.column_labels, self._block.index.names
)

columns = list(self._block.value_columns)
Expand Down Expand Up @@ -3320,7 +3321,7 @@ def _run_io_query(
session = self._block.expr.session
self._optimize_query_complexity()
export_array, id_overrides = self._prepare_export(
index=index, ordering_id=ordering_id
index=index and self._has_index, ordering_id=ordering_id
)

_, query_job = session._execute(
Expand Down
15 changes: 15 additions & 0 deletions 15 tests/system/small/test_empty_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ def test_empty_index_df_self_aligns(
)


def test_empty_index_setitem(scalars_df_empty_index, scalars_pandas_df_default_index):
bf_result = scalars_df_empty_index.copy()
bf_result["new_col"] = (
scalars_df_empty_index["int64_col"] + scalars_df_empty_index["float64_col"]
)
pd_result = scalars_pandas_df_default_index.copy()
pd_result["new_col"] = (
scalars_pandas_df_default_index["int64_col"]
+ scalars_pandas_df_default_index["float64_col"]
)
pd.testing.assert_frame_equal(
bf_result.to_pandas(), pd_result.reset_index(drop=True), check_dtype=False
)


def test_empty_index_df_concat(scalars_df_empty_index, scalars_pandas_df_default_index):
bf_result = bpd.concat([scalars_df_empty_index, scalars_df_empty_index])
pd_result = pd.concat(
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.