Repository navigation
Refactor _convert_container - #28681
Charlie-XIAO wants to merge 46 commits into
Conversation
jeremiedbb
left a comment
There was a problem hiding this comment.
Thanks for the PR @Charlie-XIAO. Here are some comments. I'm +1 for the refactoring of _convert_container.
|
Once the CIs are green, I'll review ;) (I am buying a bit of time). |
|
Now I have resolved all suggestions from Jérémie, and CI is green :) |
|
I'm going to resolve the conflicts and make a review. |
glemaitre
left a comment
There was a problem hiding this comment.
A couple of comments before to look at the tests.
adrinjalali
left a comment
There was a problem hiding this comment.
Nice work, thanks @Charlie-XIAO .
| return isinstance(X, pl.DataFrame) | ||
|
|
||
|
|
||
| def _is_arrow_df(X): |
There was a problem hiding this comment.
do we have a CI with arrow installed? (I think we should)
There was a problem hiding this comment.
Yes I think we do have it in pylatest_conda_forge_mkl_linux-64:
|
We somehow forgot about this one, would you mind updating the PR @Charlie-XIAO ? |
|
Will do tomorrow |
|
This has changed too much since I last updated. I need to take some time to check the new pyarrow-related changes to make sure I did not mistakenly drop any test, thus marking as draft now. |
|
In 11a6186 I added "pyarrow_array" under the "array" type but then realized it is more like a "series" because it can only be one-dimensional, and its primary purpose is to represent a column in a table. I'm now reverting that commit and working towards adding it as a "series" type. |
|
@adrinjalali I've added "pyarrow_array" as |
adrinjalali
left a comment
There was a problem hiding this comment.
This LGTM, and we should probably merge quick not to have more conflicts.
| return sparse_constructor(container, dtype=dtype) | ||
|
|
||
|
|
||
| def _convert_container_to_dataframe( |
There was a problem hiding this comment.
this could be probably trivialised by using narwhals 😅 (@MarcoGorelli )
There was a problem hiding this comment.
is this just used in tests (so, not user-facing)? if so, it's probably fine to use it?
|
@jeremiedbb maybe you could have another look? |
Follow up of #28521, see #28521 (comment).
This PR splits
constructor_nameintoconstructor_typeandconstructor_lib, and adds two parameterssparse_containerandsparse_formatto reflect dense versus sparse. /cc @glemaitreMapping from the original
constructor_nameto the specifications in this PRconstructor_typeconstructor_libsparse_containersparse_format"pandas"None"csr""list""list""tuple""tuple""slice""slice""array""array""sparse"/"sparse_csr""array""matrix""sparse_csc""array""matrix""csc""sparse_csr_array""array""array""sparse_csc_array""array""array""csc""dataframe"/"pandas""dataframe""polars""dataframe""polars""pyarrow""dataframe""pyarrow""series""series""polars_series""series""polars""pyarrow_array""series""pyarrow""index""index"Some rules of when each parameter is applicable
sparse_containerhas no effect unlessconstructor_type="array"sparse_formathas no effect unlessconstructor_type="array"andsparse_containeris notNoneconstructor_libhas no effect unlessconstructor_typeis one of"dataframe","series", and"index"minversionhas no effect unlessconstructor_libis usedcolumn_names(renamed fromcolumns_name) has no effect unlessconstructor_type="dataframe"categorical_feature_nameshas no effect unlessconstructor_type="dataframe"Constraints on the shape of the input container
constructor_type="slice"requires 1-dimensional container with exactly 2 elementsconstructor_type="dataframe"requires 2-dimensional container (previously it converts(n,)shape to(n, 1)shape)constructor_type="series"requires 1-dimensional container (previously it creates series with each element being a list when given 2-dimensional container)constructor_type="index"requires 1-dimensional container (similar to"series")