-
Notifications
You must be signed in to change notification settings - Fork 21
Add 2d constructor #208
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
Add 2d constructor #208
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,20 @@ def dataframe_from_dict(data: Mapping[str, Column[Any]]) -> DataFrame: | |
""" | ||
... | ||
|
||
def dataframe_from_2d_array(array: Any) -> DataFrame: | ||
""" | ||
Construct DataFrame from 2D array. | ||
|
||
See `column_from_sequece` for related 1D function. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More importantly, I foresee a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't aware, thanks just for my understanding, what makes it not a sequence? from the docs https://docs.python.org/3/glossary.html#term-sequence :
, don't arrays meet the requirement? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See data-apis/array-api#481 for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are arrays iterable per the array API? I would strongly prefer to differentiate array handling vs iterable handling since you can often handle array zero copy or at least in very efficient ways relative to iterables. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, I've added column from 1d too |
||
|
||
Only Array-API-compliant 2D arrays are supported. | ||
|
||
Returns | ||
------- | ||
DataFrame | ||
""" | ||
... | ||
|
||
class null: | ||
""" | ||
A `null` object to represent missing data. | ||
|
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.
This should have
*, names: list[str]
I think, with the length of the list matching the number of columns?Also a
dtype
keyword, because we don't really want to get in the business of inferring it (going fromarray.dtype
to a dtype in this namespace is nontrivial; much easier for the caller who has the array namespace at hand).