Skip to content

Commit 7348301

Browse files
committed
Merge branch 'master' into next-release-docs
2 parents 50766f2 + 00813b7 commit 7348301

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
### Updated
99
- Updated Plotly.js from version 2.24.1 to version 2.24.2. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2242----2023-06-09) for more information. These changes are reflected in the auto-generated `plotly.graph_objects` module.
1010
- `px` methods now accept data-frame-like objects that support a [dataframe interchange protocol](https://data-apis.org/dataframe-protocol/latest/index.html), such as polars, vaex, modin etc. This protocol has priority on `to_pandas` call, but will only be used if pandas>=2.0.2 is installed in the environment.
11+
- `px` methods now accept data-frame-like objects that support a `toPandas()` method, such as Spark DataFrames, or a `to_pandas_df()` method, such as Vaex DataFrames.
1112

1213
## [5.15.0] - 2023-06-08
1314

Diff for: packages/python/plotly/plotly/express/_core.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,12 @@ def build_dataframe(args, constructor):
13311331
elif hasattr(args["data_frame"], "to_pandas"):
13321332
args["data_frame"] = args["data_frame"].to_pandas()
13331333
columns = args["data_frame"].columns
1334+
elif hasattr(args["data_frame"], "toPandas"):
1335+
args["data_frame"] = args["data_frame"].toPandas()
1336+
columns = args["data_frame"].columns
1337+
elif hasattr(args["data_frame"], "to_pandas_df"):
1338+
args["data_frame"] = args["data_frame"].to_pandas_df()
1339+
columns = args["data_frame"].columns
13341340
else:
13351341
args["data_frame"] = pd.DataFrame(args["data_frame"])
13361342
columns = args["data_frame"].columns
@@ -1425,9 +1431,14 @@ def build_dataframe(args, constructor):
14251431
# def __dataframe__(self, ...):
14261432
# if not some_condition:
14271433
# self.to_pandas(...)
1428-
if not hasattr(df_not_pandas, "to_pandas"):
1434+
if hasattr(df_not_pandas, "toPandas"):
1435+
args["data_frame"] = df_not_pandas.toPandas()
1436+
elif hasattr(df_not_pandas, "to_pandas_df"):
1437+
args["data_frame"] = df_not_pandas.to_pandas_df()
1438+
elif hasattr(df_not_pandas, "to_pandas"):
1439+
args["data_frame"] = df_not_pandas.to_pandas()
1440+
else:
14291441
raise exc
1430-
args["data_frame"] = df_not_pandas.to_pandas()
14311442

14321443
df_input = args["data_frame"]
14331444

0 commit comments

Comments
 (0)