Skip to content

remove names from dataframe_from_2d_array #302

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 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 5 additions & 5 deletions spec/API_specification/dataframe_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
from __future__ import annotations

from typing import Mapping, Sequence, Any, Literal, TYPE_CHECKING
from typing import Dict, Sequence, Any, TYPE_CHECKING

from .column_object import *
from .dataframe_object import DataFrame
Expand Down Expand Up @@ -137,7 +137,7 @@ def column_from_1d_array(array: Any, *, dtype: DType, name: str = '') -> Column:
"""
...

def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping[str, Any]) -> DataFrame:
def dataframe_from_2d_array(array: Any, *, dtypes: Dict[str, Any]) -> DataFrame:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: but we have a schema function that is logically equivalent to what we expect here. Maybe rename this parameter to schema to be consistent?

Seeing dtypes makes me think I can pass a sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right thanks for spotting this

"""
Construct DataFrame from 2D array.

Expand All @@ -151,10 +151,9 @@ def dataframe_from_2d_array(array: Any, *, names: Sequence[str], dtypes: Mapping
----------
array : array
array-API compliant 2D array
names : Sequence[str]
Names to give columns. Must be the same length as ``array.shape[1]``.
dtypes : Mapping[str, DType]
Dtype of each column. Must be the same length as ``array.shape[1]``.
Keys determine column names.

Returns
-------
Expand Down Expand Up @@ -204,8 +203,8 @@ def is_null(value: object, /) -> bool:
bool
True if the input is a `null` object from the same library which
implements the dataframe API standard, False otherwise.

"""
...

def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
"""
Expand Down Expand Up @@ -237,6 +236,7 @@ def is_dtype(dtype: DType, kind: str | tuple[str, ...]) -> bool:
-------
bool
"""
...

def date(year: int, month: int, day: int) -> Scalar:
"""
Expand Down
1 change: 1 addition & 0 deletions spec/API_specification/dataframe_api/column_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def column(self) -> Any:
@property
def name(self) -> str:
"""Return name of column."""
...

def __len__(self) -> int:
"""
Expand Down