Skip to content
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

Big-endian issue with pandas 2.1.0 #3464

Closed
ManonMarchand opened this issue Sep 5, 2023 · 3 comments
Closed

Big-endian issue with pandas 2.1.0 #3464

ManonMarchand opened this issue Sep 5, 2023 · 3 comments
Labels

Comments

@ManonMarchand
Copy link

ManonMarchand commented Sep 5, 2023

Hello Seaborn devs and thanks for your software!

There is an issue with plotting and pandas 2.1.0 :

Doing this

import numpy as np
import seaborn as sns
x = np.array([0.5, 0.6, 0.7], dtype=np.dtype('>f4'))
y = np.array([0.5, 0.6, 0.7], dtype=np.dtype('>f4'))
sns.lineplot(x=x, y=y)

Returns the following error

Unroll for traceback

ValueError                                Traceback (most recent call last)
Cell In[3], line 5
      3 x = np.array([0.5, 0.6, 0.7], dtype=np.dtype('>f4'))
      4 y = np.array([0.5, 0.6, 0.7], dtype=np.dtype('>f4'))
----> 5 sns.lineplot(x=x, y=y)

File [~/.local/lib/python3.10/site-packages/seaborn/relational.py:638](https://file+.vscode-resource.vscode-cdn.net/home/manon.marchand/Documents/cds-astro-github/tutorials/Notebooks/~/.local/lib/python3.10/site-packages/seaborn/relational.py:638), in lineplot(data, x, y, hue, size, style, units, palette, hue_order, hue_norm, sizes, size_order, size_norm, dashes, markers, style_order, estimator, errorbar, n_boot, seed, orient, sort, err_style, err_kws, legend, ci, ax, **kwargs)
    635 if not p.has_xy_data:
    636     return ax
--> 638 p._attach(ax)
    640 # Other functions have color as an explicit param,
    641 # and we should probably do that here too
    642 color = kwargs.pop("color", kwargs.pop("c", None))

File [~/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1255](https://file+.vscode-resource.vscode-cdn.net/home/manon.marchand/Documents/cds-astro-github/tutorials/Notebooks/~/.local/lib/python3.10/site-packages/seaborn/_oldcore.py:1255), in VectorPlotter._attach(self, obj, allowed_types, log_scale)
   1253 # Now actually update the matplotlib objects to do the conversion we want
   1254 grouped = self.plot_data[var].groupby(self.converters[var], sort=False)
-> 1255 for converter, seed_data in grouped:
   1256     if self.var_types[var] == "categorical":
   1257         if self._var_ordered[var]:

File [~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/pandas/core/groupby/ops.py:604](https://file+.vscode-resource.vscode-cdn.net/home/manon.marchand/Documents/cds-astro-github/tutorials/Notebooks/~/.conda/envs/cds-tutos-dev/lib/python3.10/site-packages/pandas/core/groupby/ops.py:604), in BaseGrouper.get_iterator(self, data, axis)
    602 splitter = self._get_splitter(data, axis=axis)
    603 keys = self.group_keys_seq
...
    166     out = out.T

File pandas/_libs/algos_take_helper.pxi:1705, in pandas._libs.algos.take_1d_float32_float32()

ValueError: Big-endian buffer not supported on little-endian compiler

While it works perfectly well when reverting to pandas 2.0.0

I tried to have a look in their changelog and there is indeed some changes on dtypes but I'm not sure what the issue might be.

Also, it might be on pandas side?

@mwaskom
Copy link
Owner

mwaskom commented Sep 5, 2023

Fairly easy to reproduce in pure pandas

import numpy as np
import pandas as pd
x = np.array([0.5, 0.6, 0.7], dtype=np.dtype('>f4'))
y = np.array([0.5, 0.6, 0.7], dtype=np.dtype('>f4'))
df = pd.DataFrame({"x": x, "y": y})
list(df.groupby("x"))

Not sure if this should be expected to work or if seaborn is somehow doing something wrong here but based on this probably should be raised upstream.

@ManonMarchand
Copy link
Author

Thanks for looking!

This new snippet fails in both versions of pandas while the first one using seaborn only fails for the newest pandas. This is very strange.

On pandas side, this looks like a known issue pandas-dev/pandas#53234

@mwaskom
Copy link
Owner

mwaskom commented Nov 4, 2023

AFAICT there's no action for seaborn to take here; whether pandas is able to support this is up to them, but if they're not able to support it, I don't think it's seaborn's business to be changing the endinanness of user input data.

@mwaskom mwaskom closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants