Skip to content

fix: dedup special character #209

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 20, 2023
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
6 changes: 3 additions & 3 deletions tests/unit/core/test_bf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_get_standardized_ids_columns():
"0",
utils.UNNAMED_COLUMN_ID,
"duplicate",
"duplicate.1",
"duplicate_1",
"with_space",
]
assert idx_ids == []
Expand All @@ -37,13 +37,13 @@ def test_get_standardized_ids_indexes():

col_ids, idx_ids = utils.get_standardized_ids(col_labels, idx_labels)

assert col_ids == ["duplicate.2"]
assert col_ids == ["duplicate_2"]
assert idx_ids == [
"string",
"0",
utils.UNNAMED_INDEX_ID,
"duplicate",
"duplicate.1",
"duplicate_1",
"with_space",
]

Expand Down
10 changes: 5 additions & 5 deletions third_party/bigframes_vendored/pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def dedup_names(
"""
Rename column names if duplicates exist.

Currently the renaming is done by appending a period and an autonumeric,
but a custom pattern may be supported in the future.
Currently the renaming is done by appending a underscore and an
autonumeric, but a custom pattern may be supported in the future.

Examples
```
dedup_names(["x", "y", "x", "x"], is_potential_multiindex=False)
['x', 'y', 'x.1', 'x.2']
['x', 'y', 'x_1', 'x_2']
```
"""
names = list(names) # so we can index
Expand All @@ -34,9 +34,9 @@ def dedup_names(
if is_potential_multiindex:
# for mypy
assert isinstance(col, tuple)
col = col[:-1] + (f"{col[-1]}.{cur_count}",)
col = col[:-1] + (f"{col[-1]}_{cur_count}",)
else:
col = f"{col}.{cur_count}"
col = f"{col}_{cur_count}"
cur_count = counts[col]

names[i] = col
Expand Down