@@ -160,7 +160,7 @@ def _is_continuous(df: nw.DataFrame, col_name: str) -> bool:
160160 # fastpath for pandas: Narwhals' Series.dtype has a bit of overhead, as it
161161 # tries to distinguish between true "object" columns, and "string" columns
162162 # disguised as "object". But here, we deal with neither.
163- return df_native [col_name ].dtype .kind in ' ifc'
163+ return df_native [col_name ].dtype .kind in " ifc"
164164 return df .get_column (col_name ).dtype .is_numeric ()
165165
166166
@@ -1454,6 +1454,7 @@ def build_dataframe(args, constructor):
14541454 is_pd_like = True
14551455
14561456 elif hasattr (args ["data_frame" ], "__dataframe__" ):
1457+ # data_frame supports interchange protocol
14571458 args ["data_frame" ] = nw .from_native (
14581459 nw .from_native (
14591460 args ["data_frame" ], eager_or_interchange_only = True
@@ -1463,6 +1464,15 @@ def build_dataframe(args, constructor):
14631464 columns = args ["data_frame" ].columns
14641465 is_pd_like = True
14651466
1467+ elif hasattr (args ["data_frame" ], "toPandas" ):
1468+ # data_frame is PySpark: it does not support interchange and it is not
1469+ # integrated in narwhals just yet
1470+ args ["data_frame" ] = nw .from_native (
1471+ args ["data_frame" ].toPandas (), eager_only = True
1472+ )
1473+ columns = args ["data_frame" ].columns
1474+ is_pd_like = True
1475+
14661476 else :
14671477 try :
14681478 import pandas as pd
0 commit comments