Conversation
Will fix after running ci
| ``` | ||
| """ | ||
|
|
||
| _version: ClassVar[Version] = Version.MAIN |
There was a problem hiding this comment.
Doing this is gonna be quite handy for the rest of (#2116)
Since we're already inside the class, we can just start from the known version there
narwhals/narwhals/dataframe.py
Line 512 in 695f9ac
instead of using _stablify afterwards 😄
narwhals/narwhals/functions.py
Line 316 in f8f7f65
MarcoGorelli
left a comment
There was a problem hiding this comment.
thanks @dangotbanned !
just left a comment
| if is_eager_allowed(implementation): | ||
| ns = cls._version.namespace.from_backend(implementation).compliant | ||
| compliant = ns._dataframe.from_dict(data, schema=schema, context=ns) | ||
| return cls(compliant, level="full") | ||
| # NOTE: (#2786) needs resolving for extensions | ||
| msg = ( | ||
| f"{implementation} support in Narwhals is lazy-only, but `DataFrame.from_dict` is an eager-only function.\n\n" | ||
| "Hint: you may want to use an eager backend and then call `.lazy`, e.g.:\n\n" | ||
| f" nw.DataFrame.from_dict({{'a': [1, 2]}}, backend='pyarrow').lazy('{implementation}')" | ||
| ) | ||
| raise ValueError(msg) |
There was a problem hiding this comment.
i'm confused as to why is this necessary - if we have a DataFrame class, aren't we already eager?
There was a problem hiding this comment.
I was just adapting the existing error in nw.from_dict
narwhals/narwhals/functions.py
Lines 328 to 332 in ee06d33
Did you want this version to do something different if we wrote?
import narwhals as nw
nw.DataFrame.from_dict({'a': [1, 2]}, backend="pyspark")There was a problem hiding this comment.
ah I see sorry, this is indeed needed and correct, thanks!
my only other comment would be - do we want to repeat the docstring, or do like numpy and say "see [...] for full docstring"? probably fine to repeat?
https://numpy.org/doc/stable/reference/generated/numpy.ndarray.std.html
There was a problem hiding this comment.
"see [...] for full docstring"? probably fine to repeat?
Definitely repeat!
I'm guessing even to get that doc you'd need to not have type stubs or have a jupyter kernel running?
I'm always gonna feel strongly about IDE-experience-first-docs, since that's how I consume them 🙂
Sadly useful docs + static typing often mean we need to repeat ourselves.
But putting in that extra effort is something I really appreciate from polars vs pandas
oop yeah will do that now! |
|
(#2885 (comment)) Preview of the doc
|


What type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below
[var-annotated]by not usingSelf(695f9ac)Possible Follow-ups
Implementation.UNKNOWN#2786) fits in@overloads onbackendNamespaceDataFrame.from_dictinnw.from_dict