Skip to content

Commit

Permalink
SNOW-1730297: update docstring for to_pandas and write_pandas behavior (
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aling authored Oct 17, 2024
1 parent c62cf56 commit 50a9dcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/snowflake/snowpark/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,11 @@ def to_pandas(
2. If you use :func:`Session.sql` with this method, the input query of
:func:`Session.sql` can only be a SELECT statement.
3. For TIMESTAMP columns:
- TIMESTAMP_LTZ and TIMESTAMP_TZ are both converted to `datetime64[ns, tz]` in pandas,
as pandas cannot distinguish between the two.
- TIMESTAMP_NTZ is converted to `datetime64[ns]` (without timezone).
"""
with open_telemetry_context_manager(self.to_pandas, self):
result = self._session._conn.execute(
Expand Down
8 changes: 6 additions & 2 deletions src/snowflake/snowpark/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2628,16 +2628,20 @@ def write_pandas(
0 1 Jane
Note:
Unless ``auto_create_table`` is ``True``, you must first create a table in
1. Unless ``auto_create_table`` is ``True``, you must first create a table in
Snowflake that the passed in pandas DataFrame can be written to. If
your pandas DataFrame cannot be written to the specified table, an
exception will be raised.
If the dataframe is Snowpark pandas :class:`~modin.pandas.DataFrame`
2. If the dataframe is Snowpark pandas :class:`~modin.pandas.DataFrame`
or :class:`~modin.pandas.Series`, it will call
:func:`modin.pandas.DataFrame.to_snowflake <modin.pandas.DataFrame.to_snowflake>`
or :func:`modin.pandas.Series.to_snowflake <modin.pandas.Series.to_snowflake>`
internally to write a Snowpark pandas DataFrame into a Snowflake table.
3. If the input pandas DataFrame has `datetime64[ns, tz]` columns and `auto_create_table` is set to `True`,
they will be converted to `TIMESTAMP_LTZ` in the output Snowflake table by default.
If `TIMESTAMP_TZ` is needed for those columns instead, please manually create the table before loading data.
"""
if isinstance(self._conn, MockServerConnection):
self._conn.log_not_supported_error(
Expand Down

0 comments on commit 50a9dcf

Please sign in to comment.