Skip to content

Commit 8b58c7f

Browse files
PX can accept non-pandas dataframes that can .to_pandas()
1 parent 00c18fd commit 8b58c7f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
6+
## UNRELEASED
7+
8+
### Updated
9+
- `px` methods now accept data-frame-like objects that support a `to_pandas()` method, such as polars, cudf, vaex etc
10+
11+
512
## [5.10.0] - 2022-08-11
613

714
### Updated

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,10 @@ def build_dataframe(args, constructor):
13031303
# Cast data_frame argument to DataFrame (it could be a numpy array, dict etc.)
13041304
df_provided = args["data_frame"] is not None
13051305
if df_provided and not isinstance(args["data_frame"], pd.DataFrame):
1306-
args["data_frame"] = pd.DataFrame(args["data_frame"])
1306+
if hasattr(args["data_frame"], "to_pandas"):
1307+
args["data_frame"] = args["data_frame"].to_pandas()
1308+
else:
1309+
args["data_frame"] = pd.DataFrame(args["data_frame"])
13071310
df_input = args["data_frame"]
13081311

13091312
# now we handle special cases like wide-mode or x-xor-y specification

0 commit comments

Comments
 (0)