-
Notifications
You must be signed in to change notification settings - Fork 21
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
remove names
from dataframe_from_2d_array
#302
Conversation
@@ -135,7 +135,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: Mapping[str, Any]) -> DataFrame: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Mapping
guarantee ordering? As far as I can tell it only guarantees that __getitem__
, __len__
, and __iter__
are supported, but doesn't guarantee any specific order for __iter__
?
Not sure if this is actually an issue in practice though. Worst case we could dictate Dict
instead of Mapping
here?
@@ -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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
* remove `names` from dataframe_from_2d_array * Mapping -> Dict * rename to schema
The keys of
dtypes
already give the column names, and Python dicts are orderedIf anyone needs to reorder the names after construction, they can put
.select
after this method anywayBut having to always provide both
dtypes
andnames
is quite annoying from a user perspective