Skip to content

Commit 2ee763c

Browse files
authored
Merge branch 'main' into NO-SNOW-cp-back-snowpark-1-31-1-change
2 parents 423a36b + 83c4d3e commit 2ee763c

File tree

9 files changed

+163
-7
lines changed

9 files changed

+163
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#### New Features
2626

2727
- Added support for dict values in `Series.str.get`, `Series.str.slice`, and `Series.str.__getitem__` (`Series.str[...]`).
28+
- Added support for `DataFrame.to_html`.
2829

2930
#### Improvements
3031

docs/source/modin/dataframe.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,5 @@ DataFrame
233233
.. autosummary::
234234
:toctree: pandas_api/
235235

236-
DataFrame.to_csv
236+
DataFrame.to_csv
237+
DataFrame.to_html

docs/source/modin/supported/dataframe_supported.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ Methods
448448
+-----------------------------+---------------------------------+----------------------------------+----------------------------------------------------+
449449
| ``to_hdf`` | N | | |
450450
+-----------------------------+---------------------------------+----------------------------------+----------------------------------------------------+
451-
| ``to_html`` | N | | |
451+
| ``to_html`` | Y | | |
452452
+-----------------------------+---------------------------------+----------------------------------+----------------------------------------------------+
453453
| ``to_json`` | N | | |
454454
+-----------------------------+---------------------------------+----------------------------------+----------------------------------------------------+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def run(self):
209209
"plotly<6.0.0", # Snowpark pandas 3rd party library testing
210210
# TODO(SNOW-1938831): Test snowflake-ml-python on python 3.12 once
211211
# snowflake-ml-python is available on python 3.12.
212-
"snowflake-ml-python; python_version<'3.12'",
212+
"snowflake-ml-python>=1.8.0; python_version<'3.12'",
213213
],
214214
"localtest": [
215215
"pandas",

src/snowflake/snowpark/modin/plugin/compiler/snowflake_query_compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19259,7 +19259,6 @@ def unstack(
1925919259
self._raise_not_implemented_error_for_timedelta()
1926019260

1926119261
level = [level]
19262-
1926319262
index_names = self.get_index_names()
1926419263

1926519264
# Check to see if we have a MultiIndex, if we do, make sure we remove

src/snowflake/snowpark/modin/plugin/docstrings/dataframe.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,6 +4206,124 @@ def to_orc():
42064206
def to_html():
42074207
"""
42084208
Render a ``DataFrame`` as an HTML table.
4209+
4210+
Parameters
4211+
----------
4212+
buf : str, Path or StringIO-like, optional, default None
4213+
Buffer to write to. If None, the output is returned as a string.
4214+
4215+
columns : array-like, optional, default None
4216+
The subset of columns to write. Writes all columns by default.
4217+
4218+
col_space : str or int, list or dict of int or str, optional
4219+
The minimum width of each column in CSS length units. An int is assumed to be px units..
4220+
4221+
header : bool, optional
4222+
Whether to print column labels, default True.
4223+
4224+
index : bool, optional, default True
4225+
Whether to print index (row) labels.
4226+
4227+
na_rep : str, optional, default ‘NaN’
4228+
String representation of NaN to use.
4229+
4230+
formatters : list, tuple or dict of one-param. functions, optional
4231+
Formatter functions to apply to columns’ elements by position or name. The result of each function must be a unicode string. List/tuple must be of length equal to the number of columns.
4232+
4233+
float_format : one-parameter function, optional, default None
4234+
Formatter function to apply to columns’ elements if they are floats. This function must return a unicode string and will be applied only to the non-NaN elements, with NaN being handled by na_rep.
4235+
4236+
sparsify : bool, optional, default True
4237+
Set to False for a DataFrame with a hierarchical index to print every multiindex key at each row.
4238+
4239+
index_names : bool, optional, default True
4240+
Prints the names of the indexes.
4241+
4242+
justify : str, default None
4243+
How to justify the column labels. If None uses the option from the print configuration (controlled by set_option), ‘right’ out of the box. Valid values are
4244+
- left
4245+
- right
4246+
- center
4247+
- justify
4248+
- justify-all
4249+
- start
4250+
- end
4251+
- inherit
4252+
- match-parent
4253+
- initial
4254+
- unset.
4255+
4256+
max_rows : int, optional
4257+
Maximum number of rows to display in the console.
4258+
4259+
max_cols : int, optional
4260+
Maximum number of columns to display in the console.
4261+
4262+
show_dimensions : bool, default False
4263+
Display DataFrame dimensions (number of rows by number of columns).
4264+
4265+
decimal : str, default ‘.’
4266+
Character recognized as decimal separator, e.g. ‘,’ in Europe.
4267+
4268+
bold_rows : bool, default True
4269+
Make the row labels bold in the output.
4270+
4271+
classes : str or list or tuple, default None
4272+
CSS class(es) to apply to the resulting html table.
4273+
4274+
escape : bool, default True
4275+
Convert the characters <, >, and & to HTML-safe sequences.
4276+
4277+
notebook : {True, False}, default False
4278+
Whether the generated HTML is for IPython Notebook.
4279+
4280+
border : int
4281+
A border=border attribute is included in the opening <table> tag. Default pd.options.display.html.border.
4282+
4283+
table_id : str, optional
4284+
A css id is included in the opening <table> tag if specified.
4285+
4286+
render_links : bool, default False
4287+
Convert URLs to HTML links.
4288+
4289+
encoding : str, default “utf-8”
4290+
Set character encoding.
4291+
4292+
Returns
4293+
-------
4294+
str or None
4295+
If buf is None, returns the result as a string. Otherwise returns None.
4296+
4297+
See also
4298+
--------
4299+
to_string
4300+
Convert DataFrame to a string.
4301+
4302+
Examples
4303+
--------
4304+
>>> df = pd.DataFrame(data={'col1': [1, 2], 'col2': [4, 3]})
4305+
>>> html_string = '''<table border="1" class="dataframe">
4306+
... <thead>
4307+
... <tr style="text-align: right;">
4308+
... <th></th>
4309+
... <th>col1</th>
4310+
... <th>col2</th>
4311+
... </tr>
4312+
... </thead>
4313+
... <tbody>
4314+
... <tr>
4315+
... <th>0</th>
4316+
... <td>1</td>
4317+
... <td>4</td>
4318+
... </tr>
4319+
... <tr>
4320+
... <th>1</th>
4321+
... <td>2</td>
4322+
... <td>3</td>
4323+
... </tr>
4324+
... </tbody>
4325+
... </table>'''
4326+
>>> assert html_string == df.to_html()
42094327
"""
42104328

42114329
def to_parquet():

src/snowflake/snowpark/modin/plugin/extensions/dataframe_overrides.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ def to_orc(self, path=None, *, engine="pyarrow", index=None, engine_kwargs=None)
282282
pass # pragma: no cover
283283

284284

285-
@register_dataframe_not_implemented()
286285
def to_html(
287286
self,
288287
buf=None,
@@ -309,7 +308,10 @@ def to_html(
309308
render_links=False,
310309
encoding=None,
311310
): # noqa: PR01, RT01, D200
312-
pass # pragma: no cover
311+
WarningMessage.single_warning(
312+
"DataFrame.to_html materializes data to the local machine."
313+
)
314+
return self._to_pandas().to_html
313315

314316

315317
@register_dataframe_not_implemented()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) 2012-2025 Snowflake Computing Inc. All rights reserved.
3+
#
4+
5+
import modin.pandas as pd
6+
7+
import snowflake.snowpark.modin.plugin # noqa: F401
8+
from tests.integ.utils.sql_counter import sql_count_checker
9+
10+
html_string = """<table border="1" class="dataframe">
11+
<thead>
12+
<tr style="text-align: right;">
13+
<th></th>
14+
<th>col1</th>
15+
<th>col2</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<tr>
20+
<th>0</th>
21+
<td>1</td>
22+
<td>4</td>
23+
</tr>
24+
<tr>
25+
<th>1</th>
26+
<td>2</td>
27+
<td>3</td>
28+
</tr>
29+
</tbody>
30+
</table>"""
31+
32+
33+
@sql_count_checker(query_count=2)
34+
def test_to_html():
35+
df = pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]})
36+
assert html_string == df.to_html()

tests/unit/modin/test_unsupported.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def test_unsupported_general(general_method, kwargs):
9494
["to_feather", {"path": ""}],
9595
["to_gbq", {"destination_table": ""}],
9696
["to_hdf", {"path_or_buf": "", "key": ""}],
97-
["to_html", {}],
9897
["to_json", {}],
9998
["to_latex", {}],
10099
["to_markdown", {}],

0 commit comments

Comments
 (0)