diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce7fee72f..dcf1f1a873 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,8 @@ - Added support for `on` parameter with `Resampler`. - Added support for timedelta inputs in `value_counts()`. - Added support for applying Snowpark Python function `snowflake_cortex_summarize`. -- Added support for `DataFrame`/`Series.attrs` +- Added support for `DataFrame.attrs` and `Series.attrs`. +- Added support for `DataFrame.style`. #### Improvements diff --git a/docs/source/modin/supported/dataframe_supported.rst b/docs/source/modin/supported/dataframe_supported.rst index ea4247f2b0..c9ae49895c 100644 --- a/docs/source/modin/supported/dataframe_supported.rst +++ b/docs/source/modin/supported/dataframe_supported.rst @@ -46,7 +46,7 @@ Attributes +-----------------------------+---------------------------------+----------------------------------------------------+ | ``size`` | Y | | +-----------------------------+---------------------------------+----------------------------------------------------+ -| ``style`` | N | | +| ``style`` | Y | | +-----------------------------+---------------------------------+----------------------------------------------------+ | ``values`` | Y | | +-----------------------------+---------------------------------+----------------------------------------------------+ diff --git a/src/snowflake/snowpark/modin/plugin/docstrings/dataframe.py b/src/snowflake/snowpark/modin/plugin/docstrings/dataframe.py index 2aef74e0f0..2fc76fce50 100644 --- a/src/snowflake/snowpark/modin/plugin/docstrings/dataframe.py +++ b/src/snowflake/snowpark/modin/plugin/docstrings/dataframe.py @@ -5125,7 +5125,23 @@ def attrs(): @property def style(): - pass + """ + Returns a Styler object. + + Contains methods for building a styled HTML representation of the DataFrame. + + See Also + -------- + io.formats.style.Styler + Helps style a DataFrame or Series according to the data with HTML and CSS. + + Examples + -------- + >>> df = pd.DataFrame({'A': [1, 2, 3]}) + >>> df.style + + Please see `Table Visualization `_ for more examples. + """ def isin(): """ diff --git a/src/snowflake/snowpark/modin/plugin/extensions/dataframe_overrides.py b/src/snowflake/snowpark/modin/plugin/extensions/dataframe_overrides.py index 792217c3b3..d8803cfda0 100644 --- a/src/snowflake/snowpark/modin/plugin/extensions/dataframe_overrides.py +++ b/src/snowflake/snowpark/modin/plugin/extensions/dataframe_overrides.py @@ -382,10 +382,9 @@ def __delitem__(self, key): @register_dataframe_accessor("style") -@dataframe_not_implemented() @property def style(self): # noqa: RT01, D200 - pass # pragma: no cover + return self._to_pandas().style @register_dataframe_not_implemented() diff --git a/tests/integ/modin/frame/test_style.py b/tests/integ/modin/frame/test_style.py new file mode 100644 index 0000000000..2eff358ffe --- /dev/null +++ b/tests/integ/modin/frame/test_style.py @@ -0,0 +1,24 @@ +# +# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. +# + +import modin.pandas as pd +import pandas as npd + +from tests.integ.utils.sql_counter import sql_count_checker + +species = ["adelie"] * 3 + ["chinstrap"] * 3 + ["gentoo"] * 3 +measurements = ["bill_length", "flipper_length", "bill_depth"] * 3 +values = [37.3, 187.1, 17.7, 46.6, 191.7, 17.6, 45.5, 212.7, 14.2] + + +@sql_count_checker(query_count=1, join_count=0) +def test_simple_style_accessor(): + ndf = npd.DataFrame( + {"species": species, "measurement": measurements, "value": values} + ) + df = pd.DataFrame( + {"species": species, "measurement": measurements, "value": values} + ) + + assert df.style.to_string() == ndf.style.to_string() diff --git a/tests/unit/modin/test_unsupported.py b/tests/unit/modin/test_unsupported.py index 4a706b746f..62acffc9ae 100644 --- a/tests/unit/modin/test_unsupported.py +++ b/tests/unit/modin/test_unsupported.py @@ -93,7 +93,6 @@ def test_unsupported_general(general_method, kwargs): ["reorder_levels", {"order": ""}], ["sem", {}], ["set_flags", {}], - ["style", {}], ["swapaxes", {"axis1": "", "axis2": ""}], ["swaplevel", {}], ["to_clipboard", {}],