ColumnTransformer.fit() fails on polars.DataFrame: AttributeError: 'DataFrame' object has no attribute 'size'

### Describe the bug

Fitting a sklearn.compose.ColumnTransformer with *more than one* transformer on a polars.DataFrame yields the error:

> AttributeError: 'DataFrame' object has no attribute 'size'

* Fitting works fine when converting the DataFrame to pandas beforehand
* Fitting also works fine with a *polars* DataFrame for as long as only a *single* transformer is passed to ColumnTransformer

I am using the latest stable version of sklearn (1.7.2) and polars (1.33.1).

Thank you so much for looking into this!

### Steps/Code to Reproduce

```python
import polars as pl
from sklearn.preprocessing import OneHotEncoder
from sklearn.compose import ColumnTransformer

## Generate toy data (polars DataFrame)
df = pl.DataFrame({
    'some_categories': list('abc'),
    'some_numbers': range(3)
})

print(df)
shape: (3, 2)
┌─────────────────┬──────────────┐
│ some_categories ┆ some_numbers │
│ ---             ┆ ---          │
│ str             ┆ i64          │
╞═════════════════╪══════════════╡
│ a               ┆ 0            │
│ b               ┆ 1            │
│ c               ┆ 2            │
└─────────────────┴──────────────┘

## Define a ColumnTransformer and fit on polars df -> AttributeError
preprocessor = ColumnTransformer(
    transformers=[
        ('cat', OneHotEncoder(handle_unknown='ignore', drop='first'), ['some_categories']),
        ('num', 'passthrough', ["some_numbers"])
    ])

## Fit on polars df
preprocessor.fit(df) ## AttributeError: 'DataFrame' object has no attribute 'size'

## Fit on pandas df
preprocessor.fit(df.to_pandas()) ## works fine for pandas df


## Define ColumnTransformers with only one transformer each and fit on polars df -> works fine
preprocessor1 = ColumnTransformer(
    transformers=[
        ('cat', OneHotEncoder(handle_unknown='ignore', drop='first'), ['some_categories'])
    ])

preprocessor2 = ColumnTransformer(
    transformers=[
        ('num', 'passthrough', ["some_numbers"])
    ])

preprocessor1.fit(df) ## works
preprocessor2.fit(df) ## works
```

### Expected Results

No error.

### Actual Results

AttributeError: 'DataFrame' object has no attribute 'size'

### Versions

```shell
System:
    python: 3.12.11 (main, Jun 12 2025, 12:44:17) [MSC v.1943 64 bit (AMD64)]
executable: xxx\.venv\Scripts\python.exe
   machine: Windows-11-10.0.26100-SP0

Python dependencies:
      sklearn: 1.7.2
          pip: None
   setuptools: 80.9.0
        numpy: 2.3.2
        scipy: 1.16.1
       Cython: None
       pandas: 2.3.2
   matplotlib: 3.10.5
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
    num_threads: 20
         prefix: vcomp
       filepath: xxx\.venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 20
         prefix: libscipy_openblas
       filepath: xxx\.venv\Lib\site-packages\numpy.libs\libscipy_openblas64_-860d95b1c38e637ce4509f5fa24fbf2a.dll
        version: 0.3.30
threading_layer: pthreads
   architecture: Haswell

       user_api: blas
   internal_api: openblas
    num_threads: 20
         prefix: libscipy_openblas
       filepath: xxx\.venv\Lib\site-packages\scipy.libs\libscipy_openblas-6b2103f2ae4d8547998b5d188e9801fb.dll
        version: 0.3.28
threading_layer: pthreads
   architecture: Haswell
```

COMMENT:
Thanks for the report @ph-ll-pp. The issue comes from these lines https://github.com/scikit-learn/scikit-learn/blob/40f68d27c9e3f65c98041108ca1e16255eacbc9f/sklearn/compose/_column_transformer.py#L1016-L1020

Since here `X` can be a polars df, we need a more robust way to compute the total number of elements, like `np.prod(X.shape)`.

Would you like to submit a PR to fix it ?

Labels: Bug