Repository: narwhals-dev/narwhals

Issue:
err: raise informative error if `__getitem__` is used and first element is scalar
either that, or support it 😄 

Discussion:

Patch:
diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py
index 0f4d8e94..34e71c41 100644
--- a/narwhals/dataframe.py
+++ b/narwhals/dataframe.py
@@ -520,6 +520,17 @@ class DataFrame(BaseFrame[FrameT]):
                 2
             ]
         """
+        if (
+            isinstance(item, tuple)
+            and len(item) == 2
+            and (isinstance(item[0], (str, int)))
+        ):
+            msg = (
+                f"Expected str or slice, got: {type(item)}.\n\n"
+                "Hint: if you were trying to get a single element out of a "
+                "dataframe, use `DataFrame.item`."
+            )
+            raise TypeError(msg)
         if (
             isinstance(item, tuple)
             and len(item) == 2


Test patch:
diff --git a/tests/frame/slice_test.py b/tests/frame/slice_test.py
index 1feaaf5c..0d39f56b 100644
--- a/tests/frame/slice_test.py
+++ b/tests/frame/slice_test.py
@@ -113,3 +113,10 @@ def test_slice_int_rows_str_columns(constructor: Any) -> None:
     result = df[[0, 1], ["a", "c"]]
     expected = {"a": [1, 2], "c": [7, 8]}
     compare_dicts(result, expected)
+
+
+def test_slice_invalid(constructor: Any) -> None:
+    data = {"a": [1, 2], "b": [4, 5]}
+    df = nw.from_native(constructor(data), eager_only=True)
+    with pytest.raises(TypeError, match="Hint:"):
+        df[0, 0]