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

feat: ensure Series.str.len() can get length of array columns #497

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 1 commit into from
Mar 22, 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
2 changes: 0 additions & 2 deletions 2 tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ def nested_pandas_df() -> pd.DataFrame:
DATA_DIR / "nested.jsonl",
lines=True,
)
tests.system.utils.convert_pandas_dtypes(df, bytes_col=True)

df = df.set_index("rowindex")
return df

Expand Down
20 changes: 20 additions & 0 deletions 20 tests/system/small/operations/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,26 @@ def test_len(scalars_dfs):
)


def test_len_with_array_column(nested_df, nested_pandas_df):
"""
Series.str.len() is expected to work on columns containing lists as well as strings.

See: https://stackoverflow.com/a/41340543/101923
"""
col_name = "event_sequence"
bf_series: bigframes.series.Series = nested_df[col_name]
bf_result = bf_series.str.len().to_pandas()
pd_result = nested_pandas_df[col_name].str.len()

# One of dtype mismatches to be documented. Here, the `bf_result.dtype` is `Int64` but
# the `pd_result.dtype` is `float64`: https://github.com/pandas-dev/pandas/issues/51948
assert_series_equal(
pd_result.astype(pd.Int64Dtype()),
bf_result,
check_index_type=False,
)


def test_lower(scalars_dfs):
scalars_df, scalars_pandas_df = scalars_dfs
col_name = "string_col"
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.