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

Avoid nda.tolist() in Table.get_dataframe() when possible #32

Merged
merged 5 commits into from
Nov 3, 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
2 changes: 1 addition & 1 deletion src/lgdo/types/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Scalar(LGDO):

# TODO: do scalars need proper numpy dtypes?

def __init__(self, value: int | float, attrs: dict[str, Any] = None) -> None:
def __init__(self, value: int | float | str, attrs: dict[str, Any] = None) -> None:
"""
Parameters
----------
Expand Down
5 changes: 4 additions & 1 deletion src/lgdo/types/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def get_dataframe(
if not hasattr(column, "nda"):
raise ValueError(f"column {col} does not have an nda")
else:
df[prefix + str(col)] = column.nda.tolist()
if len(column.nda.shape) == 1:
df[prefix + str(col)] = column.nda
else:
df[prefix + str(col)] = column.nda.tolist()

return df

Expand Down
Loading