Skip to content

Commit 740a5a3

Browse files
kkleinFBruzzesi
andauthored
Update metalearners/_narwhals_utils.py
Co-authored-by: Francesco Bruzzesi <[email protected]>
1 parent 5e4b5b7 commit 740a5a3

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

metalearners/_narwhals_utils.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ def vector_to_nw(x: Vector, native_namespace: ModuleType | None = None) -> nw.Se
4747
"x is a numpy object but no native_namespace was provided to "
4848
"load it into narwhals."
4949
)
50-
# narwhals doesn't seem to like 1d numpy arrays. Therefore we first convert to
51-
# a 2d np array and then convert the narwhals DataFrame to a narwhals Series.
52-
return nw.from_numpy(x.reshape(-1, 1), native_namespace=native_namespace)[
53-
"column_0"
54-
]
50+
return nw.new_series(name="column_0", values=x, native_namespace=native_namespace)
5551
if is_into_series(x):
5652
return nw.from_native(x, series_only=True, eager_only=True)
5753
raise TypeError(f"Unexpected type {type(x)} for Vector.")

0 commit comments

Comments
 (0)