Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: make plotly-express dataframe agnostic via narwhals #4790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 131 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
9873e97
non core changes
FBruzzesi Sep 28, 2024
0389591
_core overhaul
FBruzzesi Sep 28, 2024
ba93236
some _core fixes
FBruzzesi Sep 28, 2024
421fc1d
tests replace sort_index(axis=1)
FBruzzesi Sep 28, 2024
ca5c820
reset_index in concat and allow any object to pandas
FBruzzesi Sep 28, 2024
a6aab24
trendline prep
FBruzzesi Sep 29, 2024
7665f10
WIP Index
FBruzzesi Sep 29, 2024
ec4f250
clean from breakpoints
FBruzzesi Sep 29, 2024
7e0d4c2
some tests fix
FBruzzesi Sep 29, 2024
5543638
hotfix and tests output to pandas
FBruzzesi Sep 29, 2024
cd0dab7
FIX: columns never as index
FBruzzesi Sep 29, 2024
f334b32
getting there with the tests
FBruzzesi Sep 29, 2024
e5eb949
get_column instead of pandas slicing, unix to seconds
FBruzzesi Sep 30, 2024
7747e30
bump narhwals, hierarchy fastpath
FBruzzesi Oct 1, 2024
ac00b36
fix to_unindexed_series
FBruzzesi Oct 1, 2024
da80c5b
fix trendline
FBruzzesi Oct 1, 2024
8a72ba1
rm numpy dep in _core
FBruzzesi Oct 2, 2024
aeff203
fix: _check_dataframe_all_leaves
FBruzzesi Oct 2, 2024
2041bef
(maybe) fix to_unindexed_series
FBruzzesi Oct 2, 2024
71473f1
(maybe) fix to_unindexed_series
FBruzzesi Oct 2, 2024
9f74c38
started tests with constructor
FBruzzesi Oct 2, 2024
28587c9
added constructor to all tests
FBruzzesi Oct 2, 2024
1bb2448
added some comments for fixme
FBruzzesi Oct 2, 2024
f45addf
to_py_scalar and more tests
FBruzzesi Oct 3, 2024
5341759
dealing with exceptions and tests
FBruzzesi Oct 3, 2024
dfc957c
bump version, sort(...,nulls_last=True)
FBruzzesi Oct 4, 2024
90f2667
We did it: no more dups in group by :D
FBruzzesi Oct 4, 2024
fb58d1b
concat_str
FBruzzesi Oct 5, 2024
ddb3b35
fix test_several_dataframes
FBruzzesi Oct 5, 2024
37ce302
dedups customdata
FBruzzesi Oct 5, 2024
4da8768
getting there
FBruzzesi Oct 6, 2024
210e01a
xfail pyarrow chunked-array because name-less
FBruzzesi Oct 6, 2024
c00525e
all green with edge narhwals
FBruzzesi Oct 6, 2024
3486a3e
add pandas nullable constructors in tests
FBruzzesi Oct 7, 2024
c0ce093
bump narwhals and address todos
FBruzzesi Oct 9, 2024
0eb6951
check narwhals installation
FBruzzesi Oct 9, 2024
844a6a9
rm unused comments
FBruzzesi Oct 9, 2024
0c27789
rm unused code
FBruzzesi Oct 9, 2024
0e6ff78
add pyarrow and narwhals to requirements_39_pandas_2_optional
FBruzzesi Oct 9, 2024
c2337c9
requirements, test requirements optional
FBruzzesi Oct 15, 2024
2cc5d7b
refactor tests
FBruzzesi Oct 15, 2024
1b27487
address feedbacks
FBruzzesi Oct 15, 2024
23a23be
typos
FBruzzesi Oct 15, 2024
7968cff
conftest
FBruzzesi Oct 15, 2024
cf76721
merge master
FBruzzesi Oct 15, 2024
91db84b
mock interchange
FBruzzesi Oct 15, 2024
5c6772e
optional requirements
FBruzzesi Oct 15, 2024
9ec3f9e
move conftest in express folder
FBruzzesi Oct 15, 2024
400a624
hotfix and figure_factory hexbin
FBruzzesi Oct 15, 2024
1aa5163
old versions, polars[timezone], hotfix
FBruzzesi Oct 16, 2024
594ded0
fix frame value in hexbin
FBruzzesi Oct 16, 2024
6676061
copy numpy array
FBruzzesi Oct 16, 2024
d7d2884
hotfix hexbin mapbox
FBruzzesi Oct 16, 2024
d6ee676
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Oct 16, 2024
82c114d
fix test
FBruzzesi Oct 17, 2024
0ceabc1
Merge branch 'plotly:master' into plotly-with-narwhals
FBruzzesi Oct 17, 2024
c9b626e
use lazy in process_dataframe_hierarchy
FBruzzesi Oct 17, 2024
87841d1
fix custom sort in process_dataframe_pie
FBruzzesi Oct 18, 2024
ffa7b3b
Merge branch 'master' into plotly-with-narwhals
archmoj Oct 21, 2024
3ba19ae
bump version and adjust core
FBruzzesi Oct 21, 2024
a70146b
use dtype.is_numeric
FBruzzesi Oct 22, 2024
1fa9fe4
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Oct 22, 2024
0103aa6
revert test
FBruzzesi Oct 22, 2024
673d141
Merge branch 'plotly-with-narwhals' of https://github.com/FBruzzesi/p…
FBruzzesi Oct 22, 2024
b858ed8
feedback adjustments
FBruzzesi Oct 23, 2024
bbcf438
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Oct 23, 2024
49efae2
raise if numpy is missing, conftest fix, typo
FBruzzesi Oct 25, 2024
a36bc24
__plotly_n_unique__
FBruzzesi Oct 25, 2024
c119153
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Oct 25, 2024
7416407
format
FBruzzesi Oct 25, 2024
1867f6f
format
FBruzzesi Oct 25, 2024
d3a28c0
feedback adjustments
FBruzzesi Oct 27, 2024
e6e9994
use drop_null_keys, some pandas fastpaths
MarcoGorelli Oct 25, 2024
64b8c70
bump narwhals version
MarcoGorelli Oct 27, 2024
3f6b383
some improvements by Marco
FBruzzesi Oct 27, 2024
755aea8
format and pyspark path
FBruzzesi Oct 27, 2024
6f18021
add narwhals to requirements core
FBruzzesi Oct 27, 2024
4d62e73
Update packages/python/plotly/plotly/express/_core.py
FBruzzesi Oct 28, 2024
a770fd8
refactor checking for df
MarcoGorelli Oct 29, 2024
7d6f7d6
pushdown only for interchange libraries, sort out test
MarcoGorelli Oct 29, 2024
b8c10ec
Update packages/python/plotly/plotly/express/_core.py
MarcoGorelli Oct 29, 2024
490b64a
fixup
MarcoGorelli Oct 29, 2024
f7fd4c9
Merge remote-tracking branch 'origin/plotly-with-narwhals' into plotl…
MarcoGorelli Oct 29, 2024
8753acb
lint
MarcoGorelli Oct 29, 2024
1429e6f
bump narwhals version
MarcoGorelli Oct 29, 2024
878d4db
refactor checking for df and bump version
FBruzzesi Oct 29, 2024
192e0a8
use token in process_dataframe_hierarchy
FBruzzesi Oct 29, 2024
de6761c
Range(label=...) for px.funnel
FBruzzesi Oct 29, 2024
bcfef68
improve error message and in-line comments
FBruzzesi Oct 30, 2024
519cc68
better comments
FBruzzesi Oct 30, 2024
e5520a7
rm unused import and fix typo
FBruzzesi Oct 31, 2024
b855352
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Oct 31, 2024
51e2b23
make sure column + token is unique, replace **{} with .alias()
FBruzzesi Oct 31, 2024
7ef9f28
WIP
FBruzzesi Oct 31, 2024
e9a367d
WIP
FBruzzesi Oct 31, 2024
12fed31
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Nov 1, 2024
27b2996
use nw.get_native_namespace
FBruzzesi Nov 1, 2024
f27f959
Merge branch 'plotly-with-narwhals' of https://github.com/FBruzzesi/p…
FBruzzesi Nov 1, 2024
126a79d
Merge branch 'master' into feat/dataframe-agnostic-data
FBruzzesi Nov 1, 2024
7735366
add narwhals in various requirements
FBruzzesi Nov 1, 2024
b6516b4
docstrings
FBruzzesi Nov 1, 2024
6f1389f
rm type hints, change post_agg to use alias
FBruzzesi Nov 1, 2024
db22268
feedback adjustments
FBruzzesi Nov 1, 2024
b514c01
move imports out, fix pyarrow
FBruzzesi Nov 1, 2024
ce8fb9a
rm unused narwhals wrapper
FBruzzesi Nov 1, 2024
e47827e
comment about stable api
FBruzzesi Nov 1, 2024
9a9283a
update changelog
FBruzzesi Nov 1, 2024
2630a5a
fixup time zone handling
MarcoGorelli Nov 1, 2024
fef6dbe
modin and cudf
FBruzzesi Nov 3, 2024
48c7f62
defensive from_native call
FBruzzesi Nov 4, 2024
18cc11c
typo
FBruzzesi Nov 4, 2024
d94cbf7
fixup timezones
FBruzzesi Nov 4, 2024
c320c46
move from object to datetime dtype in _plotly_utils/test/validators
FBruzzesi Nov 4, 2024
afdb31f
simplify ecdfnorm
MarcoGorelli Nov 4, 2024
68ab52a
Merge pull request #4 from MarcoGorelli/ecdf-mode-perf
FBruzzesi Nov 5, 2024
b8ccec4
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Nov 5, 2024
f102998
rm to_py_scalar call in for loop -> fix Pie performances
FBruzzesi Nov 5, 2024
2df0427
Merge branch 'plotly-with-narwhals' of https://github.com/FBruzzesi/p…
FBruzzesi Nov 5, 2024
55a0178
Merge branch 'master' into feat/dataframe-agnostic-data
FBruzzesi Nov 5, 2024
bb327d5
merge feat/dataframe-agnostic-data
FBruzzesi Nov 5, 2024
7d611fb
use return_type directly when building datasets
FBruzzesi Nov 5, 2024
a22a7be
stocks date to string and test_trendline_on_timeseries fix
FBruzzesi Nov 6, 2024
44a52e5
merge master and rm FIXME comment
FBruzzesi Nov 7, 2024
fc74b2e
do not repeat new_series unnecessarely
FBruzzesi Nov 8, 2024
499e2fa
bump version, use numpy for range
FBruzzesi Nov 8, 2024
d2e1008
trigger ci now that new version is published
FBruzzesi Nov 8, 2024
742b2ec
add narwhals to np2_optional.txt
FBruzzesi Nov 8, 2024
269dea6
version
FBruzzesi Nov 8, 2024
b1dc48d
Merge branch 'master' into plotly-with-narwhals
MarcoGorelli Nov 12, 2024
17fb96f
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Nov 12, 2024
9f2c55b
Merge branch 'master' into plotly-with-narwhals
FBruzzesi Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
defensive from_native call
  • Loading branch information
FBruzzesi committed Nov 4, 2024
commit 48c7f62bde3438fb1571fb788e61ea03e4ffae9c
6 changes: 4 additions & 2 deletions 6 packages/python/plotly/_plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
"""
np = get_module("numpy")

# Don't force pandas to be loaded, we only want to know if it's already loaded
pd = get_module("pandas", should_load=False)
assert np is not None

# ### Process kind ###
Expand All @@ -94,6 +92,10 @@ def copy_to_readonly_numpy_array(v, kind=None, force_numeric=False):
"O": "object",
}

# With `pass_through=True``, the original object will be returned if unable to convert
FBruzzesi marked this conversation as resolved.
Show resolved Hide resolved
# to a Narwhals DataFrame or Series.
v = nw.from_native(v, allow_series=True, pass_through=True)

if isinstance(v, nw.Series):
if v.dtype == nw.Datetime and v.dtype.time_zone is not None:
# Remove time zone so that local time is displayed
Expand Down
12 changes: 6 additions & 6 deletions 12 packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ def to_unindexed_series(x, name=None, native_namespace=None):
its index reset if pandas-like). Stripping the index from existing pd.Series is
required to get things to match up right in the new DataFrame we're building.
"""
x = nw.from_native(x, series_only=True, strict=False)
x = nw.from_native(x, series_only=True, pass_through=True)
if isinstance(x, nw.Series):
return nw.maybe_reset_index(x).rename(name)
elif native_namespace is not None:
Expand Down Expand Up @@ -1380,7 +1380,7 @@ def process_args_into_dataframe(
)

df_output[str(col_name)] = to_unindexed_series(
x=nw.from_native(argument, series_only=True, strict=False),
x=nw.from_native(argument, series_only=True, pass_through=True),
name=str(col_name),
native_namespace=native_namespace,
)
Expand Down Expand Up @@ -1508,11 +1508,11 @@ def build_dataframe(args, constructor):
is_pd_like = True

# data_frame is any other DataFrame object natively supported via Narwhals.
# With strict=False, the original object will be returned if unable to convert
# With pass_through=True, the original object will be returned if unable to convert
# to a Narwhals DataFrame, making this condition False.
elif isinstance(
data_frame := nw.from_native(
args["data_frame"], eager_or_interchange_only=True, strict=False
args["data_frame"], eager_or_interchange_only=True, pass_through=True
),
nw.DataFrame,
):
Expand All @@ -1521,11 +1521,11 @@ def build_dataframe(args, constructor):
columns = args["data_frame"].columns

# data_frame is any other Series object natively supported via Narwhals.
# With strict=False, the original object will be returned if unable to convert
# With pass_through=True, the original object will be returned if unable to convert
# to a Narwhals DataFrame, making this condition False.
elif isinstance(
series := nw.from_native(
args["data_frame"], series_only=True, strict=False
args["data_frame"], series_only=True, pass_through=True
),
nw.Series,
):
Expand Down
2 changes: 1 addition & 1 deletion 2 packages/python/plotly/plotly/express/_imshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def imshow(
aspect = "equal"

# --- Set the value of binary_string (forbidden for pandas)
img = nw.from_native(img, strict=False)
img = nw.from_native(img, pass_through=True)
if isinstance(img, nw.DataFrame):
if binary_string:
raise ValueError("Binary strings cannot be used with pandas arrays")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.