Skip to content

Commit 755aea8

Browse files
committed
format and pyspark path
1 parent 3f6b383 commit 755aea8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

packages/python/plotly/plotly/express/_core.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

packages/python/plotly/plotly/figure_factory/_hexbin_mapbox.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,11 @@ def create_hexbin_mapbox(
407407
center = dict(lat=lat_range.mean(), lon=lon_range.mean())
408408

409409
if args["animation_frame"] is not None:
410-
groups = dict(args["data_frame"].group_by(args["animation_frame"], drop_null_keys=True).__iter__())
410+
groups = dict(
411+
args["data_frame"]
412+
.group_by(args["animation_frame"], drop_null_keys=True)
413+
.__iter__()
414+
)
411415
else:
412416
groups = {(0,): args["data_frame"]}
413417

0 commit comments

Comments
 (0)