Skip to content
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

Fix string column bug in pandas like utils #97

Merged
merged 2 commits into from
Jan 16, 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pip install triad

## Release History

### 0.8.1

* Fixed the [string column issue](https://github.com/fugue-project/fugue/issues/415)

### 0.8.0

* Support arbitrary column name
Expand Down
3 changes: 3 additions & 0 deletions tests/utils/test_pandas_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def test_to_schema():
df = df.astype(dtype={"x": np.int32, "y": np.dtype("str")})
assert list(pa.Schema.from_pandas(df)) == list(PD_UTILS.to_schema(df))

df = pd.Series([], name="col", dtype="string").to_frame()
assert list(pa.Schema.from_pandas(df)) == list(PD_UTILS.to_schema(df))

# timestamp test
df = pd.DataFrame(
[[datetime(2020, 1, 1, 2, 3, 4, 5), date(2020, 2, 2)]], columns=["a", "b"]
Expand Down
2 changes: 1 addition & 1 deletion triad/utils/pandas_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_fields() -> Iterable[pa.Field]:
else:
for i in range(df.shape[1]):
tp = df.dtypes[i]
if tp == np.dtype("object") or tp == np.dtype(str):
if tp == np.dtype("object") or pd.api.types.is_string_dtype(tp):
t = pa.string()
else:
t = pa.from_numpy_dtype(tp)
Expand Down
2 changes: 1 addition & 1 deletion triad/utils/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def expression_to_schema(expr: str) -> pa.Schema:
except SyntaxError:
raise
except Exception as e:
raise SyntaxError(f"Invalid syntax: '{expr}' {str(e)}")
raise SyntaxError(f"Invalid syntax: '{expr}' {str(e)}") # noqa


def schema_to_expression(schema: pa.Schema) -> pa.Schema:
Expand Down
2 changes: 1 addition & 1 deletion triad_version/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# flake8: noqa
__version__ = "0.8.0"
__version__ = "0.8.1"