Skip to content

Commit 69b4d3e

Browse files
authored
Merge pull request #3901 from plotly/px_to_pandas
PX can accept non-pandas dataframes that can .to_pandas()
2 parents c3b0fda + 0e0eaa8 commit 69b4d3e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [UNRELEASED]
66

7-
87
### Updated
98
- Updated Plotly.js from version 2.20.0 to version 2.24.1. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2241----2023-06-07) for more information. Notable changes include:
109
- Add pattern to pie, funnelarea, sunburst, icicle and treemap traces [[#6601](https://github.com/plotly/plotly.js/pull/6601), [#6619](https://github.com/plotly/plotly.js/pull/6619), [#6622](https://github.com/plotly/plotly.js/pull/6622), [#6626](https://github.com/plotly/plotly.js/pull/6626), [#6627](https://github.com/plotly/plotly.js/pull/6627), [#6628](https://github.com/plotly/plotly.js/pull/6628), [#6629](https://github.com/plotly/plotly.js/pull/6629)], with thanks to @thierryVergult for the contribution!
@@ -17,6 +16,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1716
this feature was anonymously sponsored: thank you to our sponsor!
1817
- Add `legend.xref` and `legend.yref` to enable container-referenced positioning of legends [[#6589](https://github.com/plotly/plotly.js/pull/6589)], with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
1918
- Add `colorbar.xref` and `colorbar.yref` to enable container-referenced positioning of colorbars [[#6593](https://github.com/plotly/plotly.js/pull/6593)], with thanks to [Gamma Technologies](https://www.gtisoft.com/) for sponsoring the related development.
19+
- `px` methods now accept data-frame-like objects that support a `to_pandas()` method, such as polars, cudf, vaex etc
2020

2121
### Fixed
2222
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
@@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2727
- Remove `use_2to3` setuptools arg, which is invalid in the latest Python and setuptools versions [[#4206](https://github.com/plotly/plotly.py/pull/4206)]
2828
- Fix [#4066](https://github.com/plotly/plotly.py/issues/4066) JupyterLab v4 giving tiny default graph height [[#4227](https://github.com/plotly/plotly.py/pull/4227)]
2929
- Fixed issue with `colors.n_colors` where generated RGB color values were not being constrained to stay between 0 and 255 [[#4110](https://github.com/plotly/plotly.py/pull/4110)]
30+
- Fix streamline figure factory with recent versions of Numpy
3031

3132
## [5.14.1] - 2023-04-05
3233

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,10 @@ def build_dataframe(args, constructor):
13071307
# Cast data_frame argument to DataFrame (it could be a numpy array, dict etc.)
13081308
df_provided = args["data_frame"] is not None
13091309
if df_provided and not isinstance(args["data_frame"], pd.DataFrame):
1310-
args["data_frame"] = pd.DataFrame(args["data_frame"])
1310+
if hasattr(args["data_frame"], "to_pandas"):
1311+
args["data_frame"] = args["data_frame"].to_pandas()
1312+
else:
1313+
args["data_frame"] = pd.DataFrame(args["data_frame"])
13111314
df_input = args["data_frame"]
13121315

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

0 commit comments

Comments
 (0)