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

BUG: Seaborn.objects Plot.add() incompatible with Modin #5435

Closed
3 tasks done
labanyamukhopadhyay opened this issue Dec 14, 2022 · 4 comments
Closed
3 tasks done

BUG: Seaborn.objects Plot.add() incompatible with Modin #5435

labanyamukhopadhyay opened this issue Dec 14, 2022 · 4 comments
Labels
bug 🦗 Something isn't working Integration ➕➕ Issues with integrating Modin into other libraries

Comments

@labanyamukhopadhyay
Copy link
Contributor

labanyamukhopadhyay commented Dec 14, 2022

Modin version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest released version of Modin.

  • I have confirmed this bug exists on the main branch of Modin. (In order to do this you can follow this guide.)

Reproducible Example

import modin.pandas as pd
import seaborn as sns
import seaborn.objects as so

ex_tips_df = pd.DataFrame({'total_bill': [16.99, 10.34, 21.01], 'tip': [1.01, 1.66, 3.50], 'sex': ['Female', 'Male', 'Male'], 'smoker': ['No', 'No', 'Yes'], 'day': ['Sun', 'Sun', 'Sun'], 'time': ['Dinner', 'Dinner', 'Dinner'], 'size': [2, 3, 3]})

so.Plot(ex_tips_df, "total_bill", "tip").add(so.Dot())

Issue Description

The add() function results in KeyError: 'x'and works in Pandas. However, so.Plot(ex_tips_df["total_bill"], ex_tips_df["tip"]).add(so.Dot()) runs successfully.

Expected Behavior

Screen Shot 2022-12-13 at 5 42 16 PM

Error Logs

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File ~/Desktop/ponder-integ/lib/python3.9/site-packages/pandas/core/indexes/base.py:3803, in Index.get_loc(self, key, method, tolerance)
   3802 try:
-> 3803     return self._engine.get_loc(casted_key)
   3804 except KeyError as err:

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/pandas/_libs/index.pyx:138, in pandas._libs.index.IndexEngine.get_loc()

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/pandas/_libs/index.pyx:165, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:5745, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:5753, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'x'

The above exception was the direct cause of the following exception:

KeyError                                  Traceback (most recent call last)
File ~/Desktop/ponder-integ/lib/python3.9/site-packages/IPython/core/formatters.py:342, in BaseFormatter.__call__(self, obj)
    340     method = get_real_method(obj, self.print_method)
    341     if method is not None:
--> 342         return method()
    343     return None
    344 else:

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/seaborn/_core/plot.py:278, in Plot._repr_png_(self)
    276 def _repr_png_(self) -> tuple[bytes, dict[str, float]]:
--> 278     return self.plot()._repr_png_()

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/seaborn/_core/plot.py:820, in Plot.plot(self, pyplot)
    816 """
    817 Compile the plot spec and return the Plotter object.
    818 """
    819 with theme_context(self._theme_with_defaults()):
--> 820     return self._plot(pyplot)

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/seaborn/_core/plot.py:850, in Plot._plot(self, pyplot)
    848 # Process the data for each layer and add matplotlib artists
    849 for layer in layers:
--> 850     plotter._plot_layer(self, layer)
    852 # Add various figure decorations
    853 plotter._make_legend(self)

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/seaborn/_core/plot.py:1350, in Plotter._plot_layer(self, p, layer)
   1347     grouping_vars = mark._grouping_props + default_grouping_vars
   1348     split_generator = self._setup_split_generator(grouping_vars, df, subplots)
-> 1350     mark._plot(split_generator, scales, orient)
   1352 # TODO is this the right place for this?
   1353 for view in self._subplots:

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/seaborn/_marks/dot.py:70, in DotBase._plot(self, split_gen, scales, orient)
     62 def _plot(self, split_gen, scales, orient):
     63 
     64     # TODO Not backcompat with allowed (but nonfunctional) univariate plots
     65     # (That should be solved upstream by defaulting to "" for unset x/y?)
     66     # (Be mindful of xmin/xmax, etc!)
     68     for _, data, ax in split_gen():
---> 70         offsets = np.column_stack([data["x"], data["y"]])
     71         data = self._resolve_properties(data, scales)
     73         points = mpl.collections.PathCollection(
     74             offsets=offsets,
     75             paths=data["path"],
   (...)
     83             **self.artist_kws,
     84         )

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/pandas/core/frame.py:3805, in DataFrame.__getitem__(self, key)
   3803 if self.columns.nlevels > 1:
   3804     return self._getitem_multilevel(key)
-> 3805 indexer = self.columns.get_loc(key)
   3806 if is_integer(indexer):
   3807     indexer = [indexer]

File ~/Desktop/ponder-integ/lib/python3.9/site-packages/pandas/core/indexes/base.py:3805, in Index.get_loc(self, key, method, tolerance)
   3803     return self._engine.get_loc(casted_key)
   3804 except KeyError as err:
-> 3805     raise KeyError(key) from err
   3806 except TypeError:
   3807     # If we have a listlike key, _check_indexing_error will raise
   3808     #  InvalidIndexError. Otherwise we fall through and re-raise
   3809     #  the TypeError.
   3810     self._check_indexing_error(key)

KeyError: 'x'

Installed Versions

INSTALLED VERSIONS

commit : 4114183
python : 3.9.7.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

Modin dependencies

modin : 0.18.0+3.g4114183f
ray : 2.0.1
dask : 2022.11.1
distributed : 2022.11.1
hdk : None

pandas dependencies

pandas : 1.5.2
numpy : 1.23.5
pytz : 2022.6
dateutil : 2.8.2
setuptools : 57.4.0
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.7.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2022.11.0
gcsfs : None
matplotlib : 3.6.2
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : 2022.11.0
scipy : 1.9.3
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None

@labanyamukhopadhyay labanyamukhopadhyay added bug 🦗 Something isn't working Triage 🩹 Issues that need triage labels Dec 14, 2022
@YarShev
Copy link
Collaborator

YarShev commented Dec 14, 2022

@dorisjlee, @mvashishtha, do we have any plans on the roadmap to support compatibility between Modin and other libraries? Is lux suitable to already work with Modin?

@mvashishtha
Copy link
Collaborator

@YarShev we'd like to support compatibility, but there's no such effort planned in the near term. @labanyamukhopadhyay @dorisjlee do you know if lux is already compatible?

@anmyachev anmyachev added Integration ➕➕ Issues with integrating Modin into other libraries and removed Triage 🩹 Issues that need triage labels Dec 15, 2022
@labanyamukhopadhyay
Copy link
Contributor Author

This specific issue is resolved when installing seaborn from its master branch due to recent support of dataframe interchange protocol

A more common example so.Plot(ex_tips_df, x= 'total_bill', y= 'tip', color='smoker').add(so.Dot()) also now works thanks to #6523

@mvashishtha
Copy link
Collaborator

This specific issue is resolved when installing seaborn from its master branch due to recent support of mwaskom/seaborn#3369

@labanyamukhopadhyay that's great! thank you for checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🦗 Something isn't working Integration ➕➕ Issues with integrating Modin into other libraries
Projects
None yet
Development

No branches or pull requests

4 participants